im working with color based image retrieval..i have array cell containing list filename..how can i display them in gui using for loop??
MATLAB: How can i display image from array element of cell?
image processingImage Processing Toolboxmatlab guiprocess a sequence of files
Related Solutions
Do you want to
- crop it away, which will give a different size image?
- Or set it to white, which would leave the image the same size?
Also, what does "Enhacing" mean? No such word. Does it mean "enhancing" or "erasing"? If erasing, you need to answer my questions as to how you want to erase (get rid of) the black border. If enhancing, you need to define exactly what that means.
To crop you could use imcrop() but it's probably easiest to just use indexing:
img = img(row1 : row2, col1 : col2, :); % Works for either rgb or grayscale image.
I assume you can find the rows and columns and that it's known and fixed for all images. If it moves around and changes size (which is doubtful but possible), you'd need code to find them.
I see no reason why imquantize() won't work. Please show your code that demonstrates why imquantize() fails.
Alternatively you can use mat2gray followed by multiplication, as this demo shows:
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear; % Erase all existing variables.
workspace; % Make sure the workspace panel is showing.
format longg;format compact;fontSize = 15;% Read in a standard MATLAB gray scale demo image.
folder = fullfile(matlabroot, '\toolbox\images\imdemos');button = menu('Use which demo image?', 'CameraMan', 'Moon', 'Eight', 'Coins', 'Pout');if button == 1 baseFileName = 'cameraman.tif';elseif button == 2 baseFileName = 'moon.tif';elseif button == 3 baseFileName = 'eight.tif';elseif button == 4 baseFileName = 'coins.png';else baseFileName = 'pout.tif';end% Read in a standard MATLAB gray scale demo image.folder = fullfile(matlabroot, '\toolbox\images\imdemos');baseFileName = baseFileName;% Get the full filename, with path prepended.
fullFileName = fullfile(folder, baseFileName);% Check if file exists.
if ~exist(fullFileName, 'file') % File doesn't exist -- didn't find it there. Check the search path for it.
fullFileName = baseFileName; % No path this time.
if ~exist(fullFileName, 'file') % Still didn't find it. Alert user.
errorMessage = sprintf('Error: %s does not exist in the search path folders.', fullFileName); uiwait(warndlg(errorMessage)); return; endendgrayImage = imread(fullFileName);% Get the dimensions of the image.
% numberOfColorBands should be = 1.
[rows columns numberOfColorBands] = size(grayImage);% Display the original gray scale image.
subplot(2, 2, 1);imshow(grayImage, []);title('Original Grayscale Image', 'FontSize', fontSize);% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);% Give a name to the title bar.
set(gcf,'name','Demo by ImageAnalyst','numbertitle','off') % Let's compute and display the histogram.
[pixelCount grayLevels] = imhist(grayImage);subplot(2, 2, 2); bar(pixelCount);grid on;title('Histogram of original image', 'FontSize', fontSize);xlim([0 grayLevels(end)]); % Scale x axis manually.
% Quantize
numberOfGrayLevels = 4;quantizedImage = uint8(mat2gray(grayImage) * (numberOfGrayLevels-1));% Display the original gray scale image.subplot(2, 2, 3);imshow(quantizedImage, []);caption = sprintf('Image quantized into %d gray levels', numberOfGrayLevels);title(caption, 'FontSize', fontSize);% Enlarge figure to full screen.set(gcf, 'units','normalized','outerposition',[0 0 1 1]);% Give a name to the title bar.set(gcf,'name','Demo by ImageAnalyst','numbertitle','off') % Let's compute and display the histogram.[pixelCount grayLevels] = imhist(quantizedImage);subplot(2, 2, 4); bar(pixelCount);grid on;caption = sprintf('Histogram of image quantized into %d gray levels', numberOfGrayLevels);title(caption, 'FontSize', fontSize);lastGL = find(pixelCount>0, 1, 'last');xlim([0 lastGL+1]); % Scale x axis manually.
Best Answer