I want to 2-D plot the grayscale image values.The below code plot the 3-D values of a grayscale image.What i can use
instead of meshgrid function to plot 2-D values of a gray scale image.Please see the pictures for more details.
Ix = imread('C:\Users\Haseeb\Desktop\images\capture.jpg');
I= rgb2gray(Ix);
x = 1:size(I,1);
y = 1:size(I,2);
[X,Y] = meshgrid(x,y);
figure,plot3(X,Y,I)

 채택된 답변

Ameer Hamza
Ameer Hamza 2018년 5월 2일

0 개 추천

You can plot it using histcounts().
counts = histcounts(grayImage, 0:256)
plot(counts)

댓글 수: 4

Haseeb Hassan
Haseeb Hassan 2018년 5월 3일
편집: Haseeb Hassan 2018년 5월 3일
Thanks.Excellent it works.But we should replace 0:255 instead of
0:256.Now i am trying to get the smoothed plot of this converted
grayscale image plot. Can you help by coding that. In picture you can
see.I will be very thankful i am stuck in this since few days.
Ameer Hamza
Ameer Hamza 2018년 5월 3일
I am not well-versed in signal processing. You have a better chance of getting an answer if you start a new question.
As i applied your plotting code within my code, further smoothed the
converted plot by Gaussian Filter , now i want to reconstruct the
image from the plot can you help to reconstruct from plot.
Ix = imread('capture.jpg');
I= rgb2gray(Ix);
counts = histcounts(I, 0:255);
figure, plot(counts);
%Filter the image with a Gaussian filter with standard deviation of 2
Iblur = imgaussfilt(counts, 0.7);
%Display all results for comparison.
figure,plot(Iblur)
title('Gaussian filtered image, \sigma = 2');
Ameer Hamza
Ameer Hamza 2018년 5월 4일
You cannot recover an image back from this plot because the information about the location of each pixel is lost. Can you think of a way by which I can know which pixel belongs to which location by just looking at this plot?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

질문:

2018년 5월 2일

댓글:

2018년 5월 4일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by