Loading MatLab .fig file as an Image

5 次查看(过去 30 天)
Good day,
I have recently cropped an image and saved is at a .fig MatLab file so that I can plot out and edit its histogram in the future. Currently I am unsure of how to load the image such that I can do my histogram.
I read online about hgload, but when I load it and plot, it only shows 1 point in the histogram.
Can anyone guide me?
Regards Guan Zhao

采纳的回答

Image Analyst
Image Analyst 2012-9-22
That's inefficient and confusing. Just take the histogram again when you want it later, or if you want to save the histogram itself, just save the histogram with save(). Don't save a displayed figure, with all its background, axes tick marks, etc. and then try to get back to the original image from a figure - it just doesn't make sense.
% Save the cropped image
imwrite( croppedImageArray, fullFileName);
% or save the histogram
[pixelCounts grayLevels] = imhist(croppedImageArray);
save(fullMATFileName, 'pixelCounts', 'grayLevels');
  5 个评论
Image Analyst
Image Analyst 2012-9-22
编辑:Image Analyst 2012-9-22
I don't know why your imwrite call didn't work then. It should work.
I gave you code for the histogram. You can examine the output arguments in the debugger's variable editor. Or try
bar(grayLevels, pixelCounts);

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Histograms 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by