Determine average of an image in .fig format
Mostrar comentarios más antiguos
Hi all,
I've saved a number of images as .fig as a result of extensive computations in Matlab 2007b. However, I would like to glean some extra info from these images without having to reprocess all files. I simply want to get the mean of a number of values dictated by a defined region (set by rect()). Is this possible? Obviously my matrices of values are no longer in memory, in which case this would be easy. I've been using uiopen to view the files; is there another option that would allow me to perform this?
Any advice would be appreciated, Kista
Respuesta aceptada
Más respuestas (3)
Shashank Prasanna
el 8 de Feb. de 2013
Editada: Shashank Prasanna
el 8 de Feb. de 2013
Here is an example you can hopefully modify it for your use:
% Create a figure with a rectangle:
rectangle('Position',[0.59,0.35,3.75,1.37],'LineWidth',2,'LineStyle','--')
hgsave(gcf,'rect.fig'); % you can save it manually from file if you like.
h = importdata('rect.fig');
pos = h.children.children.properties.Position
pos =
0.5900 0.3500 3.7500 1.3700
How did i find the position properties, well you can just explore the entire 'h' structure, depending on what type of image you have you can extract the properties appropriately. You can later maybe do a sum average etc.
Image Analyst
el 8 de Feb. de 2013
Just avoid the problem in the first place. Don't save images as .fig files. Save them as image files, for example .PNG files. Then you simply read it back in with imread() and get the mean with mean2():
grayImage = imread(fullFileName);
theMean = mean2(grayImage(row1:row2, col1:col2));
Susan
el 11 de Feb. de 2013
0 votos
1 comentario
Image Analyst
el 11 de Feb. de 2013
Saving as a fig file is a mistake. Save the variables in a mat file and you'll be able to get the numbers out exactly as they were.
Categorías
Más información sobre Graphics Objects en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!