필터 지우기
필터 지우기

Getting following error,wht is the solution

조회 수: 2 (최근 30일)
Poonam
Poonam 2013년 9월 22일
* * *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(:)];

답변 (1개)

Image Analyst
Image Analyst 2013년 9월 22일
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.

카테고리

Help CenterFile Exchange에서 Linear Least Squares에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by