Prev: Types of video file formats in Mat lab
Next: mex
From: Nehal on 10 Jul 2010 05:13 I need to crop an object without changing the image into binary. I cannot crop the object manually by putting positions/co-ordinates. In my case, the object is a hand. Background is black and the hand is white. I need to crop out the hand without converting the image to binary. The RGB image is here: http://www.mediafire.com/?znwngzjydn3 Can anyone help me..?
From: Image Analyst on 10 Jul 2010 07:27 Find the edges of the hand somehow, for example when the summed profiles pass some threshold. verticalProfile = mean(imageArray, 2); horizontalProfile = mean(imageArray, 1); row1 = find(verticalProfile > thresholdvalue, 1, 'first'); row2 = find(verticalProfile > thresholdvalue, 1, 'last'); column1 = find(horizontalProfile > thresholdvalue, 1, 'first'); column2 = find(horizontalProfile > thresholdvalue, 1, 'last'); You have to determine thresholdvalue of course. Then call imcrop(). width = abs(column2-column1)+1; height = abs(row2-row1)+1; croppedImage = imcrop(rgbImage, [row1 column1 width height]);
From: Nehal on 10 Jul 2010 09:50 "Image Analyst" <imageanalyst(a)mailinator.com> wrote in message <i19le9$kgv$1(a)fred.mathworks.com>... > Find the edges of the hand somehow, for example when the summed profiles pass some threshold. > verticalProfile = mean(imageArray, 2); > horizontalProfile = mean(imageArray, 1); > > row1 = find(verticalProfile > thresholdvalue, 1, 'first'); > row2 = find(verticalProfile > thresholdvalue, 1, 'last'); > > column1 = find(horizontalProfile > thresholdvalue, 1, 'first'); > column2 = find(horizontalProfile > thresholdvalue, 1, 'last'); > > You have to determine thresholdvalue of course. > Then call imcrop(). > > width = abs(column2-column1)+1; > height = abs(row2-row1)+1; > croppedImage = imcrop(rgbImage, [row1 column1 width height]); Can you suggest some thresholdvalues...? I have tried some values like 0.5, 0.7 ect. But it's not working. Can you suggest me a range of values that I should try...? and... > croppedImage = imcrop(rgbImage, [row1 column1 width height]); should it be the RGB image or the gray image...? Thanks.
From: Image Analyst on 10 Jul 2010 10:49 Without seeing an image so I can look at it's histogram, you want me to suggest a threshold value? Maybe you can try the triangle threshold method. It works well for many real world situations: http://www.mathworks.com/matlabcentral/fileexchange/28047-gray-image-thresholding-using-the-triangle-method Otherwise, just import your image into a more interactive program, like ImageJ or Photoshop and see what threshold works.
From: Walter Roberson on 10 Jul 2010 11:54
Nehal wrote: > "Image Analyst" <imageanalyst(a)mailinator.com> wrote in message > <i19le9$kgv$1(a)fred.mathworks.com>... >> Find the edges of the hand somehow, for example when the summed >> profiles pass some threshold. verticalProfile = mean(imageArray, 2); >> horizontalProfile = mean(imageArray, 1); >> >> row1 = find(verticalProfile > thresholdvalue, 1, 'first'); >> row2 = find(verticalProfile > thresholdvalue, 1, 'last'); > Can you suggest some thresholdvalues...? Not germaine, as ImageAnalyst's method implicitly converts the image to binary ('>' returns a binary result) and thus does not satisfy your requirement that the image must not be converted to binary. Not that I can think of a good reason why you would impose such a requirement as long as your _output_ was full color, but I guess you have your reasons. |