Borrar filtros
Borrar filtros

Getting following error,wht is the solution

2 visualizaciones (últimos 30 días)
Poonam
Poonam el 22 de Sept. de 2013
* * *This is demo Part* * *
% Change the current folder to the folder of this m-file.
if(~isdeployed)
cd(fileparts(which(mfilename)));
end
try
% Check that user has the Image Processing Toolbox installed.
hasIPT = license('test', 'image_toolbox');
if ~hasIPT
% User does not have the toolbox installed.
message = sprintf('Sorry, but you do not seem to have the Image Processing Toolbox.\nDo you want to try to continue anyway?');
reply = questdlg(message, 'Toolbox missing', 'Yes', 'No', 'Yes');
if strcmpi(reply, 'No')
% User said No, so exit.
return;
end
end
catch ME
errorMessage = sprintf('Error running this m-file:\n%s\n\nThe error message is:\n%s', ...
mfilename('fullpath'), ME.message);
errordlg(errorMessage);
end
% Continue with the demo. Do some initialization stuff.
close all;
fontSize = 14;
figure;
% Maximize the figure.
set(gcf, 'Position', get(0, 'ScreenSize'));
set(gcf,'name','image','numbertitle','off')
% Change the current folder to the folder of this m-file.
% (The line of code below is from Brett Shoelson of The Mathworks.)
if(~isdeployed)
cd(fileparts(which(mfilename)));
end
% Ask user if they want to use a demo image or their own image.
message = sprintf('Do you want use a standard demo image,\nOr pick one of your own?');
reply2 = questdlg(message, 'Which Image?', 'Demo','My Own', 'Demo');
% Open an image.
if strcmpi(reply2, 'Demo')
% Read standard MATLAB demo image.
message = sprintf('Which demo image do you want to use?');
selectedImage = questdlg(message, 'Which Demo Image?', 'Onions', 'Peppers', 'Stained Fabric', 'Onions');
if strcmp(selectedImage, 'Onions')
fullImageFileName = 'onion.png';
elseif strcmp(selectedImage, 'Peppers')
fullImageFileName = 'peppers.png';
else
fullImageFileName = 'fabric.png';
end
else
% They want to pick their own.
% Change default directory to the one containing the standard demo images for the MATLAB Image Processing Toolbox.
originalFolder = pwd;
folder = fullfile(matlabroot,'\toolbox\images\imdemos');
if ~exist(folder, 'dir')
folder = pwd;
end
cd(folder);
% Browse for the image file.
[baseFileName, folder] = uigetfile('*.*', 'Specify an image file');
fullImageFileName = fullfile(folder, baseFileName);
% Set current folder back to the original one.
cd(originalFolder);
selectedImage = 'My own image'; % Need for the if threshold selection statement later.
end
% Check to see that the image exists. (Mainly to check on the demo images.)
if ~exist(fullImageFileName, 'file')
message = sprintf('This file does not exist:\n%s', fullImageFileName);
WarnUser(message);
return;
end
im=imread(fullImageFileName);
%im1=rgb2luv;
r=im(:,:,1);
g=im(:,:,2);
b=im(:,:,3);
[r1,c]=meshgrid(1:size(im,1),1,size(im,2));
* *data_vecs=[r(:),g(:),b(:),r1(:),c(:)];* *
[data_idxs centroids]=kmeansseg(data_vecs,k);
d=reshape(data_idxs,size(im,1),size(i,2));
subplot(221),imshow(im),title('Original image'),suplot(222),imshow(d),title('kmean clustered image');
  • getting following error *
??? Error using ==> horzcat CAT arguments dimensions are not consistent.
Error in ==> kmeanssegdemo at 81 data_vecs=[r(:),g(:),b(:),r1(:),c(:)];

Respuestas (1)

Image Analyst
Image Analyst el 22 de Sept. de 2013
When you set a breakpoint on that line, what does it tell you the sizes of r,g,b,r1, and c are? Evidently they're not all the same size - that's what "dimensions are not consistent." means.

Categorías

Más información sobre Linear Least Squares en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by