Prev: summing arrays in a loop
Next: DitrectTorqueControl_SRM
From: ImageAnalyst on 1 May 2010 16:25 On May 1, 2:48 pm, Bhuvan <kushalbhu...(a)yahoo.co.in> wrote: > ??? Undefined function or method 'sqrt' for input arguments of type 'uint8'. > > Error in ==> Untitled7 at 16 > deltaE = sqrt(deltaLImage.^2 + deltaAImage.^2 + deltaBImage.^2); > > steve Y is this??? ------------------------------------------------------------------------------------------- I'm not Steve but I'll answer. You need to cast them to double like in this demo: clc; % Clear the command window. close all; % Close all figures (except those of imtool.) imtool close all; % Close all imtool figures. clear; % Erase all existing variables. workspace; % Make sure the workspace panel is showing. % 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 % Read in standard MATLAB color demo image. rgbImage1 = imread('peppers.png'); subplot(3, 4, 1); imshow(rgbImage1, []); title('Original Color Image'); set(gcf, 'Position', get(0,'Screensize')); % Enlarge figure to full screen. % Generate a second image from the first one. rgbImage2 = imnoise(rgbImage1, 'gaussian', 0, 0.02) * 0.95; subplot(3, 4, 5); imshow(rgbImage2, []); title('Other Color Image'); % Get the rgb to lab transform and convert both images. cform = makecform('srgb2lab'); lab1 = applycform(rgbImage1,cform); lab2 = applycform(rgbImage2,cform); % Extract the component images like this: LImage1 = double(lab1(:,:,1)); AImage1 = double(lab1(:,:,2)); BImage1 = double(lab1(:,:,3)); LImage2 = double(lab2(:,:,1)); AImage2 = double(lab2(:,:,2)); BImage2 = double(lab2(:,:,3)); % Display all the lab images. subplot(3, 4, 2); imshow(LImage1, []); title('L1 Image'); subplot(3, 4, 3); imshow(AImage1, []); title('A1 Image'); subplot(3, 4, 4); imshow(BImage1, []); title('B1 Image'); subplot(3, 4, 6); imshow(LImage2, []); title('L2 Image'); subplot(3, 4, 7); imshow(AImage2, []); title('A2 Image'); subplot(3, 4, 8); imshow(BImage2, []); title('B2 Image'); deltaLImage = LImage1 - LImage2; deltaAImage = AImage1 - AImage2; deltaBImage = BImage1 - BImage2; subplot(3, 4, 10); imshow(deltaLImage, []); title('Delta L Image'); subplot(3, 4, 11); imshow(deltaAImage, []); title('Delta A Image'); subplot(3, 4, 12); imshow(deltaBImage, []); title('Delta B Image'); % Get the Delta E image: deltaEImage = sqrt(deltaLImage.^2 + deltaAImage.^2 + deltaBImage.^2); meanDeltaE = mean(deltaEImage(:)); subplot(3, 4, 9); imshow(deltaEImage, []); title('Delta E Image'); message = sprintf('Done!\nThe mean Delta E (color difference) = %.2f', meanDeltaE); msgbox(message); %---------------------- end of code---------------------------------- However I don't think those are actual CIELAB values so treat them as relative. A and B values generally go between about -20 and +20, not 0-255 like the transform is giving. -ImageAnalyst (not Steve - a different person)
From: Walter Roberson on 1 May 2010 22:09 Bhuvan wrote: > ??? Undefined function or method 'sqrt' for input arguments of type 'uint8'. > > Error in ==> Untitled7 at 16 > deltaE = sqrt(deltaLImage.^2 + deltaAImage.^2 + deltaBImage.^2); > > > steve Y is this??? Because it didn't seem worthwhile to go through the complete testing phase for a function that only has 16 possible outputs, and which would surely get badly misused if it existed. You go an error message and were thus alerted to the problem that you are trying to take integer square roots. If Mathworks had provided the code, then you would have been completely baffled as to why the program ran but your outputs were almost all 15. Remember, when you do arithmetic using uint8, values "saturate" at the maximum uint8, 255, so if any of your input values had been 16 or greater, the square of that input would have saturated at 255; adding more things to that would have left you with 255, and the integer square root would then have been 15 (15*15 is the the greatest square number less than or equal to 255.) Thus, by NOT providing the code, Mathworks made your program easier to debug. If you REALLY want the uint8 square root code, we could probably come up with something pretty efficient and fairly compact... and mostly useless.
From: Bhuvan on 4 May 2010 06:23 hey thanks a lot.....it works perfectly... i'm also doing sketch based search...what i have done is to rangefilt the image so that the edges get prominent then take std value of the image...it works when when ur sketch is of same size as that of the picture...do have any better ideas how sketch based search can be made...in this user searches the images based on the sketch he draws....
From: Bhuvan on 4 May 2010 06:30 yea thanks....i'm trying to do sketch based search i got this code for freehand draw function [lineobj,xs,ys] = freehanddraw(varargin) % [LINEOBJ,XS,YS] = FREEHANDDRAW(ax_handle,line_options) % % Draw a smooth freehand line object on the current axis (default), % or on the axis specified by handle in the first input argument. % Left-click to begin drawing, right-click to terminate, or double-click % to close contour and terminate. % % % INPUT ARGUMENTS: First: axis handle (optional) % Additional: valid line property/value pairs % % OUTPUT ARGUMENTS: 1) Handle to line object % 2) x-data % 3) y-data % (Note that output args 2 and 3 can also be extracted from the first output % argument.) % % Ex: [myobj,xs,ys] = freehanddraw(gca,'color','r','linewidth',3); % freehanddraw('linestyle','--'); % % Written by Brett Shoelson, PhD % shoelson(a)helix.nih.gov % 3/29/05 % Modified: % 10/05/05: Now allows double-click closing of contour axdef = 0; if nargin ~= 0 & ishandle(varargin{1}) try axes(varargin{1}); axdef = 1; catch error('If the initial input argument is a handle, it must be to a valid axis.'); end end %Get current figure and axis parameters oldvals = get(gcf); oldhold = ishold(gca); %hold on; set(gcf,'Pointer','crosshair','doublebuffer','on'); %Get the initial point [xs,ys,zs] = ginput(1); %Create and store line object if axdef lineobj = line(xs,ys,'tag','tmpregsel',varargin{2:end}); else lineobj = line(xs,ys,'tag','tmpregsel',varargin{:}); end setappdata(gcf,'lineobj',lineobj); %Modify wbmf of current figure to update lineobject on mouse motion set(gcf,'windowbuttonmotionfcn',@wbmfcn); %fdsd disp('stop'); set(gcf,'windowbuttondownfcn',@wbdfcn); %Wait for right-click or double-click while ~strcmp(get(gcf,'SelectionType'),'alt') & ~strcmp(get(gcf,'SelectionType'),'open') drawnow; end %Extract xyz data from line object for return in output variables %(Also retrievable from first output argument) if nargout > 1 xs = get(getappdata(gcf,'lineobj'),'xdata')'; end if nargout > 2 ys = get(getappdata(gcf,'lineobj'),'ydata')'; end %Clear temporary variables from base workspace evalin('caller','clear tmpx tmpy tmpz done gca lineobj'); %Reset figure parameters set(gcf,'Pointer',oldvals.Pointer,... 'windowbuttonmotionfcn',oldvals.WindowButtonMotionFcn,... 'windowbuttondownfcn',oldvals.WindowButtonDownFcn,... 'doublebuffer',oldvals.DoubleBuffer); %Reset hold value of the axis if ~oldhold, hold off; end function wbmfcn(varargin) lineobj = getappdata(gcf,'lineobj'); if strcmp(get(gcf,'selectiontype'),'normal'); tmpx = get(lineobj,'xdata'); tmpy = get(lineobj,'ydata'); a=get(gca,'currentpoint'); %set(a,'units',points); % set(a,'xlim',[0,1],'ylim',[0,1]); % if(a==1) set(lineobj,'xdata',[tmpx,a(1,1)],'ydata',[tmpy,a(1,2)]); %else % a=1; %end drawnow; else setappdata(gcf,'lineobj',lineobj); end function wbdfcn(varargin) lineobj = getappdata(gcf,'lineobj'); if strcmp(get(gcf,'selectiontype'),'open') tmpx = get(lineobj,'xdata'); tmpy = get(lineobj,'ydata'); a=get(gca,'currentpoint'); set(a,'xlim',[0,1],'ylim',[0,1]); set(lineobj,'xdata',[tmpx,tmpx(1)],'ydata',[tmpy,tmpy(1)]); setappdata(gcf,'lineobj',lineobj); drawnow; end return but it doesn't work.... the first mouse click on the figure generates a random line...then it's fine why is it so?
From: ImageAnalyst on 4 May 2010 11:54 On May 4, 10:23 am, Bhuvan <kushalbhu...(a)yahoo.co.in> wrote: > hey thanks a lot.....it works perfectly... > i'm also doing sketch based search...what i have done is to rangefilt the image so that the edges get prominent then take std value of the image...it works when when ur sketch is of same size as that of the picture...do have any better ideas how sketch based search can be made...in this user searches the images based on the sketch he draws.... ------------------------------------------------------------- No, I've only heard about it but I've never worked in that field.
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 4 Prev: summing arrays in a loop Next: DitrectTorqueControl_SRM |