Borrar filtros
Borrar filtros

Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

Error in sub plot when I resize Image to divide it to blocks ,can any one solve it?

1 visualización (últimos 30 días)
I use this code from math works but I change the new size of resizing function and I get this error
clc; % Clear the command window.
format compact;
workspace; % Make sure the workspace panel is showing.
fontSize = 20;
% Read in a standard MATLAB color demo image.
folder = fullfile(matlabroot, '\toolbox\images\imdemos');
baseFileName = 'peppers.png';
fullFileName = fullfile(folder, baseFileName);
% Get the full filename, with path prepended.
fullFileName = fullfile(folder, baseFileName);
if ~exist(fullFileName, 'file')
% 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.', fullFileName);
uiwait(warndlg(errorMessage));
return;
end
end
rgbImage = imread(fullFileName);
% For demo purposes, let's resize it to be 64 by 64;
rgbImage = imresize(rgbImage, [512 512]);
% Get the dimensions of the image. numberOfColorBands should be = 3.
[rows columns numberOfColorBands] = size(rgbImage)
ca = mat2cell(rgbImage,8*ones(1,size(rgbImage,1)/8),8*ones(1,size(rgbImage,2)/8),3);
plotIndex = 1;
for c = 1 : size(ca, 2)
for r = 1 : size(ca, 1)
fprintf('c=%d, r=%d\n', c, r);
subplot(256,256,plotIndex);
x=ca{r,c};
size(x)
imshow(x);
plotIndex = plotIndex + 1
end
end
% Enlarge figure to full screen.
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
The original resizing was to 64*64

Respuestas (1)

Image Analyst
Image Analyst el 21 de Mzo. de 2015
It worked for me, other than being real slow. What was the error message you got? By the way, change
subplot(256,256,plotIndex);
to
subplot(64, 64, plotIndex);
and put a drawnow after the r loop, just before the end of the c loop.
  2 comentarios
Ameligege
Ameligege el 21 de Mzo. de 2015
what do you mean by"put a drawnow after the r loop, just before the end of the c loop." ?
Ameligege
Ameligege el 21 de Mzo. de 2015
The Error was in subplot ,but now I am trying this code after your solution but it does not show the output? Because I want to see the blocks of the same size 8*8

La pregunta está cerrada.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by