unknown image format on axes in MATLAB

I'm working on CBIR, in my GUI I've 6 axes one for query image 5 for resulted images. For displaying images on axes my code is
function displayResults(filename,hObject, eventdata, handles)
% Open 'filename' file... for reading...
fid = fopen(filename);
for N=6:1:10
imagename = fgetl(fid);
if ~ischar(imagename), break, end % Meaning: End of File...
x=imread(imagename);
axes(handles.(sprintf('axes%d', N)));
imshow(x)
xlabel(imagename);
end
fclose(fid);
and calling function is in pushbutton function Texture_Callback(hObject, eventdata, handles). calling function is
displayResults('textureResults.txt',hObject, eventdata, handles);
What just happened to image quality?
Before using above code i was getting clear images, but that was not a GUI window, instead just a figure window. any thing wrong in called function?

5 Comments

Try
ax = handles.(sprintf('axes%d', N));
imshow(x, 'Parent', ax);
xlabel(ax, imagename);
Chethan
Chethan on 4 May 2013
Edited: Walter Roberson on 4 May 2013
imshow(x, 'Parent', ax); results in same clarity. However i used image(x, 'Parent', ax); and this resulted in http://s1273.photobucket.com/user/Chethan_tv/media/fig_zpsa48de802.jpg.html?sort=3&o=0 what had happened to quality of other images?
Hmmm... As an experiment, after the assignment to "ax", add
hold(ax, 'off')
well, that resulted in same output. As you said i added hold(ax, 'off') after the assignment to "ax" i.e., above image(x, 'Parent', ax);. . and it didn't work. How can i remove those map values(x and y axis values)?
Not sure what "map values(x and y axis values)" are - I didn't see any axis values or tick marks, but if you have some there now, just say "axis off" to get rid of them. If you have a colorbar, you can say
colormap(gray(256));
colorbar off;
to get rid of the colorbar and go back to a normal display.

Sign in to comment.

Answers (1)

Can you plot the histogram in one of those axes so I can look at it. Here's a snippet of code:
% Let's compute and display the histogram.
[pixelCount, grayLevels] = imhist(grayImage);
bar(pixelCount);
grid on;
title('Histogram of original image', 'FontSize', fontSize);
xlim([0 grayLevels(end)]); % Scale x axis manually.
Then see if the histogram (pixelCount) ends around mid-100s and then is all zeros until there is a big spike at element #256.

13 Comments

Well i tried above code without title('Histogram of original image', 'FontSize', fontSize); because i got an error
_Undefined function or variable 'fontSize'.
Error in ==> Fig5>displayResults at 103
title('Histogram of original image', 'FontSize', fontSize);
Error in ==> Fig5>Texture_Callback at 150
displayResults('textureResults.txt',hObject, eventdata, handles);
Error in ==> gui_mainfcn at 96
feval(varargin{:});
_
where, figure1 window is histogram of first clear image and figure2 window is of second distorted image.
So, define it. Or just use a constant, like 14 or something. Or just get rid of it altogether. There are any number of ways to fix that.
title('Histogram of original image', 'FontSize', 14);
And your link didn't work, but I fixed it. But I don't see any bright white specks in your image there. It looks fine to me.
Chethan
Chethan on 4 May 2013
Edited: Image Analyst on 4 May 2013
But for my query image, all 5 results should be clear. before using this code i was getting good clarity images.
Now only first image is good, what happened to other 4?
Histogram count results in
where, figure1 window is histogram of first clear image and figure2 window is of second distorted image.
Upload the original images so I can check. Right now, I don't want screenshots anymore - I want the original 5 images.
This result i got using
function displayResults(filename, header)
figure('Position',[200 100 700 400], 'MenuBar', 'none', 'Name', header, 'Resize', 'off', 'NumberTitle', 'off');
% Open 'filename' file... for reading...
fid = fopen(filename);
i = 1; % Subplot index on the figure...
while 1
imagename = fgetl(fid);
if ~ischar(imagename), break, end % Meaning: End of File...
[x, map] = imread(imagename);
subplot(2,5,i);
subimage(x, map);
xlabel(imagename);
i = i + 1;
end
fclose(fid);
since i want to display images in my GUI i changed my code. In my GUI i should get all images like this in mentioned axes.
Upload the original images so I can check. Right now, I don't want screenshots anymore - I want the original 5 images.
They appear to be indexed images so you need to display using the colormap. And you cannot do image analysis on those image values. Also, the first two values of the colormap look messed up for some reason. Perhaps you misunderstood something when you saved/created the image.
No, my question is if i use separate figure window i'll get correct output, but if i use GUI as you can see in above links few images are not clear. why is it so?
I don't know, but I'd attack the root cause - that the images are indexed images with a screwed up colormap instead of a normal grayscale image. Who created these images in the first place?
I only created images, with a purpose. For my CBIR code i need bitmap image of bit depth 8. So using photoshop software i created these images and my database is full of this type of images.
In photoshop: image>mode>indexed color and 8-bit/channel, finally i saved it as .bmp format
Why did you do that? Why did you not use grayscale? (They were saved as PNG, which is good though, better than BMP, so at least you did something right.)
Anyways finally i got good clarity output. simply i changed final image to RGB, then i displayed
[x,map]=imread(imagename);
rgb=ind2rgb(x,map);
ax = handles.(sprintf('axes%d', N));
hold(ax, 'off');
image(rgb, 'Parent', ax);
Thank you for your guidance.

Sign in to comment.

Tags

Asked:

on 3 May 2013

Community Treasure Hunt

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

Start Hunting!