Borrar filtros
Borrar filtros

display image informations via gui using imfinfo

1 visualización (últimos 30 días)
matlab22 el 16 de Mayo de 2014
Respondida: matlab22 el 16 de Mayo de 2014
hello , i am tried to show (display) the informations of images wich i load them and applicate a defferents tests of denoising, i used a push-button and text-edit , button to display informations, so, for exemple i need to show the width:
function push-button_Callback(hObject, eventdata, handles) global image
nothing appears and i get this errors
??? Error using ==> imfinfo at 96 Unable to open file "image" for reading.
Error in ==> app>info_Callback at 1741 info=imfinfo('image');
Error in ==> gui_mainfcn at 96 feval(varargin{:});
Error in ==> app at 42 gui_mainfcn(gui_State, varargin{:});
Error in ==> @(hObject,eventdata)app('info_Callback',hObject,eventdata,guidata(hObject))
??? Error while evaluating uicontrol Callback

Respuesta aceptada

Benjamin Avants
Benjamin Avants el 16 de Mayo de 2014
First, I would suggest not using a global variable to store your image or images. It would be better to save the image data to the handles data structure.
% load image
% process image
% display image
handles.image = image;
This way, any callback that needs the image data can retrieve it from the handles structure and you don't need to use the global variable. You can do this with any shared data or variable in a GUI created with guide.
The problem in your code is that imfinfo() requires a filename as a parameter, not a loaded image. If all you want is the width of the image in pixels, you can get it from the size of the image data.
width = size(image,1);
height = size(image,2);
width = size(handles.image,1);
height = size(handles.image,2); % If you've stored the image in the handles data structure
If you need other info about the file, you can either compute it yourself or get it from the file when you load the image and store it in the handles structure.
image = imread('image.bmp'); = imfinfo('image.bmp');
If the information about the image that you're looking for changes after you've processed the image, you'll either need to save the new image as a file and then use imfinfo or, as mentioned, compute the new information yourself.

Más respuestas (1)

matlab22 el 16 de Mayo de 2014
thanks for the answer,
width = size(image,1); height = size(image,2);
works perfectly, but the probleme that i must load differnet image formats bmp,jpg,gif,png how can i give imfinfo the fmt each time i load an image: = imfinfo('image.bmp'); % .bmp or jpg or .......
and for real i wanna display more than the width but also filename ,size ,width ,higth.


Más información sobre Geometric Transformation and Image Registration en Help Center y File Exchange.


Community Treasure Hunt

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

Start Hunting!

Translated by