I'm trying to make a 3d plot of the pixel intensity in an image, however I cannot seem to make my code work
조회 수: 2 (최근 30일)
이전 댓글 표시
So I want to be able to import an image (of stars in the sky), and make a 3D plot of the pixel intensity, so that the stars are easily identifiable as "spikes" in the surface.
I've got this code that other's says should work:
J = imread('IMG_1442.jpg');
I = imresize(J,.2)
[x y]=meshgrid(1:size(I,1), 1:size(I,2));
scatter3(x(:),y(:),I(:),15,I(:),'filled');
axis tight; colormap gray
But whenever I run it I get the following error:
Error using scatter3 (line 94)
X, Y and Z must be vectors of the same length.
Error in image_test (line 4)
scatter3(x(:),y(:),I(:),15,I(:),'filled');
(The reason I resize the image is because it is extremely large. I've attached a compressed version of the file so that you can see what I'm working with)
댓글 수: 0
답변 (1개)
Walter Roberson
2016년 4월 13일
JPEG images are almost always RGB images, even when they look like black and white. The number of pixel components in an RGB image is 3 times larger than you are expecting. You should convert to grayscale before doing the scatter plot.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Line Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!