how to project image into (x,y) coordinates graph
29 views (last 30 days)
Show older comments
I have an image and wish to project the pixel details into graphical form in which x,y coordinates are pixel position and pixel number and vice versa. Can anyone help me
Answers (2)
Walter Roberson
on 2 Jan 2018
YourImage = imread('shadow_remove.
jpg') ;
GreyImage = rgb2gray(YourImage) ; %jpeg are rarely rarely greyscale files even if they look to be
plot(GreyImage(:))
2 Comments
Walter Roberson
on 3 Jan 2018
The horizontal and vertical projection are max(GreyImage,[],1) and max(GreyImage,[],2) which you could then plot() or bar() to display.
Guillaume
on 3 Jan 2018
If I understood correctly you have a binary image and you want the pixel count (which you call the pixel number) along each column and along each row:
%binaryimage: a binary image
xwidth = 1:size(binaryimage, 2);
xcount = sum(binaryimage, 1);
yheight = 1:size(binaryimage, 1);
ycount = sum(binaryimage, 2);
You can plot that any number of ways, e.g.:
figure;
subplot(1, 2, 1);
bar(xwidth, xcount);
xlabel('pixel position along x');
ylabel('pixel count');
title('horizontal histogram');
subplot(1, 2, 2);
barh(yheight, ycount);
xlabel('pixel count');
ylabel('pixel position along y');
title('vertical histogram');
0 Comments
See Also
Categories
Find more on Subplots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!