Prev: Windows 7 Home Premium vs. Windows 7 Professional (using MATLAB R2007a or R2007b)
Next: extract field in excel
From: AZZA Foster on 25 Apr 2010 13:43 Does anyone know if it is possible to create charcteristic parameters for bwboundaries?? e.g. bwboundaries (image,charcteristic); charcteristic = [0111000000000, 0111000000000, 0111000000000, 0111111111100, 0111111111100, 0000000000000;]; Something that basically identifies an L shape??
From: ImageAnalyst on 25 Apr 2010 14:46 Not that I'm aware of. That is not an allowable argument for bwboundaries(). You'd have to try something else like imfilter, nlfilter, conv2, or something like that to basically make up a "hit or miss filter". Or you can try a Harris corner detector if you're looking to find corners.
From: ImageAnalyst on 25 Apr 2010 15:16 This looks like a machine vision application. Therefore you can crop the image to known coordinates since your 2D bar code should be in pretty much the same position in every image. If this is not the case then you need to shelve your image processing until you get control of your image acquisition situation (which looks pretty bad at the moment). It's always better to start with a good image rather than a bad one.
From: AZZA Foster on 25 Apr 2010 17:52 Thanks for the reply Image analyst Yes this will be part of an image acquisition system. The image was pulled from the internet. The image is about the resolution you would get from a CCD camera. The barcode would be clearer in actual use as the camera will be mounted above the image more or less central and will also be closer. I have already made a few changes to the code above but i want to try and get my program working with this image as if it can pic up this barcode it should be able to pick up others with ease especially in the situation above. image(Image3);figure(gcf); axis square; Image4 = Image3 >= 100; scaled2 = Image4 * 1.0; level = graythresh (scaled2); bw = im2bw (scaled2, level); bw = bwareaopen (bw, 6); bw = ~bw; horizontalProfile = max(~bw, [], 1); x1 = find(horizontalProfile, 1, 'first'); x2 = find(horizontalProfile, 1, 'last'); verticalProfile =max(~bw, [], 2); y1 = find(verticalProfile, 1, 'first'); y2 = find(verticalProfile, 1, 'last'); boxX = [x1 x2 x2 x1 x1]; boxY = [y1 y1 y2 y2 y1]; imshow(bw, []); hold on; plot (boxX,boxY,'r-'); cornerim = cornermetric (bw); cornerim_adjusted = imadjust (cornerim); corner_peaks = imregionalmax (cornerim_adjusted); corner_idx = find(corner_peaks == true); [r g b] = deal (cornerim); r(corner_idx) = 255; g(corner_idx) = 255; b(corner_idx) = 0; RGB = cat(3,r,g,b); figure, imshow (RGB); I might abandon the corner detection method and have inverted the original image and will try a density and border detection approach.
From: ImageAnalyst on 25 Apr 2010 20:07
Maybe you could use a variance filter (go here http://www.mathworks.com/matlabcentral/newsreader/view_thread/279711#737209 for a demo I posted on that this year). Then use morphological closing to clump them (the dots) together, and then threshold and find big blobs. Do a hole fill, then bwlabel and regionprops and finally filter looking for a certain shape factor (perimeter squared over area) that is representative of squares. Or else try to find the pattern using a tophat (imtophat()) or bottom hat filter. Or you could try a hit or miss filter (bwhitmiss()) to try to find the black dots surrounded by white areas. But this works on a binary image so you need to have an image that can be thresholded nicely before you can do this, a limitation the variance filter doesn't have. |