From: AZZA Foster on
I have a Black and White image in which i would like to create a boundary box around a specific part.

In order to do this i need to somehow identify this region which has a large L shape around the data. ( The image is a 2D data matrix barcode) I wish to identify this L shape and draw a boundary box around the whole image.

I thinking of using the filt2 which is an ROI filter but im not sure how to implement it???
I appreciate any comments made
From: ImageAnalyst on
Where's your image?
Post it to http://drop.io or somewhere, and then we can offer
suggestions. It's hard for me to visualize a bar code with some L-
shaped region around it, and what you consider the "whole image" to
be. I.e. wouldn't a box around the "whole image" just be a box on the
top row, bottom row, left column and right column? Or did you mean a
box around the bar code, or around the L-shaped region? I'm also
unclear as to why you're thinking of using a filter to find the region
- a photo would help me understand that.
From: AZZA Foster on
Here is my image http://drop.io/ifihag5 , i have used the follwing to convert to black and white and extract the corners:
%%%%%%%%%%%%%%%%%%%%%%%

image(Image3);figure(gcf);
Image4 = Image3 >= 100;
scaled2 = Image4 * 1.0;
level = graythresh (scaled2);
bw = im2bw (scaled2, level);
bw = bwareaopen (bw, 6);
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_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 Now need to tell Matlab to select an area with say 200 to 300 yellow blobs within a certain area of pixels and draw a box round it. This should pick out only the barcode. I can then overlay that box on the original image.
From: AZZA Foster on
I think i have to define the yellow pixel areas as a blob definition.
so target area of 200x200 pixels, look for 80 - 150 blobs of pixel colour r = 1, g = 1 and b = 0;
Then are all the blobs in a 200x200 pixel area.

Im looking at something along these lines, just trying to figure out functions and code values.
From: AZZA Foster on
Sorry the above code is incorrect, try this one LOL.

%%%%%%%%%%%%%%%%%%%%%%%%%%

image(Image3);figure(gcf);
Image4 = Image3 >= 100;
scaled2 = Image4 * 1.0;
level = graythresh (scaled2);
bw = im2bw (scaled2, level);
bw = bwareaopen (bw, 6);
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);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%