Loading MatLab .fig file as an Image

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 日

0 投票

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 件のコメント

Guan Zhao
Guan Zhao 2012 年 9 月 22 日
I am figuring out how to save the cropped image so that I will be able to work with it again in the future.
I tried saving with your recommendation using 'imwrite' as shown below
imwrite(I2, 'C:\Users\Desktop\MatLab\Test.JPG', jpg);
The code did not proceed to the next line, so I presume it got stuck at this line. Any idea what is wrong with this line?
Image Analyst
Image Analyst 2012 年 9 月 22 日
Is I2 a uint8 color or grayscale image? What does
>> whos I2
report back? I2 is not single or double is it? Also, the third argument jpg is not needed - it will determine the image file format from the extension of the filename you passed it.
Guan Zhao
Guan Zhao 2012 年 9 月 22 日
I2 is an uint8 grayscale image. I am trying to determine the pixel intensity for starters on my cloud project, if you still remember you answered my previous post too.
Anyway on a sidenote, is it possible to show the no. of samples in an image histogram? (The no. of data values used to plot the histogram)
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);
Guan Zhao
Guan Zhao 2012 年 9 月 22 日
Alright I got it! Thanks!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Community Treasure Hunt

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

Start Hunting!

Translated by