unknown image format on axes in MATLAB
Show older comments
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);
before pressing pushbutton http://s1273.photobucket.com/user/Chethan_tv/media/fig5_zps64ca6452.jpg.html?sort=3&o=1
after pressing pushbutton http://s1273.photobucket.com/user/Chethan_tv/media/fig5_zps98c96f8f.jpg.html?sort=3&o=0
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
Walter Roberson
on 3 May 2013
Try
ax = handles.(sprintf('axes%d', N));
imshow(x, 'Parent', ax);
xlabel(ax, imagename);
Chethan
on 4 May 2013
Edited: Walter Roberson
on 4 May 2013
Walter Roberson
on 4 May 2013
Hmmm... As an experiment, after the assignment to "ax", add
hold(ax, 'off')
Chethan
on 4 May 2013
Image Analyst
on 4 May 2013
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.
Answers (1)
Image Analyst
on 4 May 2013
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
Chethan
on 4 May 2013
Edited: Image Analyst
on 4 May 2013
Image Analyst
on 4 May 2013
Edited: Image Analyst
on 4 May 2013
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
on 4 May 2013
Edited: Image Analyst
on 4 May 2013
Image Analyst
on 4 May 2013
Upload the original images so I can check. Right now, I don't want screenshots anymore - I want the original 5 images.
Chethan
on 5 May 2013
Edited: Walter Roberson
on 5 May 2013
Image Analyst
on 5 May 2013
Upload the original images so I can check. Right now, I don't want screenshots anymore - I want the original 5 images.
Chethan
on 5 May 2013
Image Analyst
on 5 May 2013
Edited: Image Analyst
on 5 May 2013
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.
Chethan
on 5 May 2013
Image Analyst
on 5 May 2013
Edited: Image Analyst
on 5 May 2013
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?
Chethan
on 5 May 2013
Image Analyst
on 5 May 2013
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.)
Chethan
on 5 May 2013
Categories
Find more on White in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!