how to find coordinate of corner of label image

5 views (last 30 days)
Please help this problem :
i have problem , i already process my image : <http://tinypic.com/view.php?pic=2czer0o&s=6>
and then this my image after process label : <http://tinypic.com/view.php?pic=fbgcbm&s=6>
but have message error : ? ?? Function 'find' is not defined for values of class 'cell'. Error in ==> mathcorner at 67 upperLeftCornerX = find(B(1,:), 1, 'first'); __________________________
error found when i tried to find corner coordintae of label image .. this my code :
%clear all;
%close all;
rgbImage = imread('IM.jpg');
% Get the dimensions of the image. numberOfColorBands should be = 3.
[rows columns numberOfColorBands] = size(rgbImage);
% Extract the individual red, green, and blue color channels.
% redChannel = rgbImage(:, :, 1);
% greenChannel = rgbImage(:, :, 2);
blueChannel = rgbImage(:, :, 3);
imshow(blueChannel, []);
% Threshold blue channel
binaryImage = blueChannel < 198;
% Get rid of small blobs.
binaryImage = bwareaopen(binaryImage, 10000);
% Fill in any holes in the tile.
binaryImage = imfill(binaryImage, 'holes');
% Display it.
imshow(binaryImage, []);
% Display it.
imshow(binaryImage, []);
SE = strel ('disk', 5);
i1 = imerode(binaryImage, SE);
figure, imshow(i1, []);
BWc1 = imclearborder(i1,1);
figure, imshow(BWc1, []);
SE = strel('disk', 2, 0)
i1 = imclose (BWc1, SE);
figure, imshow(i1, []);
[x, y, rgb] =ind2sub ([size(i1,1) size(i1, 2) size(i1,3)], find (i1~= 255));
A = i1 (min(x): max(x)-1, min(y):max(y)-1,:);
M = im2double(A);
e1 = edge (M, 'canny');
figure, imshow(e1, []);
wx = [-1 -2 -1; 0 0 0; 1 2 1];
wy = [-1 0 1; -2 0 2; -1 0 1];
wx1= [-2 -1 0; -1 0 1; 0 1 2];
wy1= [0 1 2; -1 0 1; -2 -1 0];
gx= imfilter(double(e1),wx, 'replicate');
gy= imfilter(double(e1),wy, 'replicate');
gx1= imfilter(double(e1),wx1, 'replicate');
gy1= imfilter(double(e1),wy1, 'replicate');
g = gx + gy + gx1+ gy1;
figure, imshow (g, []);
[B,L] = bwboundaries(g,'holes');
% Display the label matrix and draw each boundary
imshow(label2rgb(L, @jet, [.1 .1 .1]))
hold on
for k = 1:length(B)
boundary = B{k};
plot(boundary(:,2), boundary(:,1), 'w', 'LineWidth', 1)
end
%find coorndinate ,,
upperLeftCornerX = find(B(1,:), 1, 'first');
upperRightCornerX = find(B(1,:), 1, 'last');
lowerLeftCornerX = find(B(end,:), 1, 'first');
lowerRightCornerX = find(B(end,:), 1, 'last');
upperLeftCornerX
upperRightCornerX
lowerLeftCornerX
lowerRightCornerX

Answers (0)

Categories

Find more on Image Processing Toolbox in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!