Prev: Windows 7 Home Premium vs. Windows 7 Professional (using MATLAB R2007a or R2007b)
Next: extract field in excel
From: AZZA Foster on 29 Apr 2010 12:54 Here is my code with more corrections, i just need help with the loop's and the operators, thanks in advance AZZA K = 1; %% (INITIAL CONDITION)This is set so that only a clockwise or anticlockwise function is performed in the first 2 cycles of the program loop %% %% Rotate subimage by 1 degree clockwise %% if K = 1; Loop CW rotatedsubimage = imrotate (subimage,1) %% After rotation performed update subimage bounding box%% horizontalProfile = max(subimage, [], 1); x1 = find(horizontalProfile, 1, 'first'); x2 = find(horizontalProfile, 1, 'last'); verticalProfile =max(subimage, [], 2); y1 = find(verticalProfile, 1, 'first'); y2 = find(verticalProfile, 1, 'last'); boxX = [x1 x2 x2 x1 x1]; boxY = [y1 y1 y2 y2 y1]; end %% Rotate subimage by 1 degree counterclockwise %% Loop CCW rotatedsubimage = imrotate (subimage,-1) %% After rotation performed update subimage bounding box%% horizontalProfile = max(subimage, [], 1); x1 = find(horizontalProfile, 1, 'first'); x2 = find(horizontalProfile, 1, 'last'); verticalProfile =max(subimage, [], 2); y1 = find(verticalProfile, 1, 'first'); y2 = find(verticalProfile, 1, 'last'); boxX = [x1 x2 x2 x1 x1]; boxY = [y1 y1 y2 y2 y1]; end %% update subimage bounding box before performing size calculations, THEN loop %% horizontalProfile = max(rotatedsubimage, [], 1); x3 = find(horizontalProfile, 1, 'first'); x4 = find(horizontalProfile, 1, 'last'); verticalProfile =max(rotatedsubimage, [], 2); y3 = find(verticalProfile, 1, 'first'); y4 = find(verticalProfile, 1, 'last'); boxX2 = [x3 x4 x4 x3 x3]; boxY2= [y3 y3 y4 y4 y3]; %% Compare, is the rotated bounding box larger or smaller than subimage(original) %% if the y2 axis is smaller than y1 axis and x2 is smaller than x1 carry on rotating%% if y4 <= y2 , x4 <= x2; goto "Loop CW" %% goto Loop Clockwise end %% if y2 is greater than y1 and x2 is greater than x1, then the image area is getting bigger,go counterclockwise instead %% if y4 > y2 , x4 > x2; goto "Loop CCW" end %% If rotatedsubimage bounding box(y4,x4) is equal to subimage boundingbox (x2,y2) %% if y4 == y2, x4 == x2; %% when both bounding boxs are the same size,the image is central%% end %%carry on with rest of code %%
From: ImageAnalyst on 29 Apr 2010 13:12 I don't have time to help you with this today. Maybe tomorrow if we're lucky, but maybe not. And I could only do it if you uploaded your cropped 2D bar code picture as a regular image (PNG, BMP, etc.) rather than a MATLAB fig file.
From: AZZA Foster on 29 Apr 2010 13:24 ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <7ee4eaa1-5489-4dc8-b762-4490234a8319(a)v37g2000vbv.googlegroups.com>... > I don't have time to help you with this today. Maybe tomorrow if > we're lucky, but maybe not. And I could only do it if you uploaded > your cropped 2D bar code picture as a regular image (PNG, BMP, etc.) > rather than a MATLAB fig file. No worries ill upload all the files tonight if im still stuck, thanks AZZA
From: AZZA Foster on 30 Apr 2010 08:00 I have found out why my code is running in a continous loop, i am using the imrotate function, this function places a BLACK canvas on an area where it does not know what pixel to assign to that space, so anyone know how to tell image rotate to apply a WHITE canvas to rotated images???
From: AZZA Foster on 30 Apr 2010 08:15
"AZZA Foster" <Aaron.Foster17(a)ntlworld.com> wrote in message <hregol$j32$1(a)fred.mathworks.com>... > I have found out why my code is running in a continous loop, i am using the imrotate function, this function places a BLACK canvas on an area where it does not know what pixel to assign to that space, so anyone know how to tell image rotate to apply a WHITE canvas to rotated images??? Just had another thought, is it possible to use an image mask to lay the original NON rotated image over the rotated image and extract all Black pixels that do not match the masked image?? (This should remove the canvas pixels) |