Boundaries in an image
Hi,
I have to trace the boundaries in the image (attached original image).
I have to trace only one boundary as indicated in the image.
I tried this for only one image, how can I do this for number of images?
Waiting for a kind response.
Regards
Tayyaba
grayImage = imread(‘0002.tif’);
[rows, columns, numberOfColorChannels] = size(grayImage);
if numberOfColorChannels > 1
grayImage = rgb2gray(grayImage);
end
% Display the image.
subplot(2, 3, 1);
imshow(grayImage, []);
title(‘Original Grayscale Image’);
impixelinfo;
% Crop image
% grayImage = imcrop(grayImage);
Img = imcrop(grayImage,[670 60 800 500]);
% Update size.
[rows, columns, numberOfColorChannels] = size(Img);
%——————————————————————————————————–
% SEGMENTATION OF IMAGE
% Get a binary image
mask = Img < 22; %imbinarize(grayImage);
% Display the mask.
subplot(2, 3, 4);
imshow(mask, []);
impixelinfo;
title(‘Initial Binary Image’);
impixelinfo;
% Fill interior holes.
mask = imfill(mask, ‘holes’);
% Get rid of particles smaller than 10000 in size
mask = bwareaopen(mask,10000);
subplot(2, 3, 5);
imshow(mask, []);
impixelinfo;
title(‘Final Binary Image’);
impixelinfo;
% Get boundaries
boundaries = bwboundaries(mask);
subplot(2, 3, 6);
imshow(grayImage); % Show cropped image again.
hold on;
for k = 1 : length(boundaries)
thisBoundary = boundaries{k};
x = thisBoundary(:, 2);
y = thisBoundary(:, 1);
plot(x, y, ‘r-‘, ‘LineWidth’, 2);
end
%Specifing limits to get rid of the outer boundary
xlim([5 500]);
ylim([5 500]);
title(‘Image With Boundaries’);Hi,
I have to trace the boundaries in the image (attached original image).
I have to trace only one boundary as indicated in the image.
I tried this for only one image, how can I do this for number of images?
Waiting for a kind response.
Regards
Tayyaba
grayImage = imread(‘0002.tif’);
[rows, columns, numberOfColorChannels] = size(grayImage);
if numberOfColorChannels > 1
grayImage = rgb2gray(grayImage);
end
% Display the image.
subplot(2, 3, 1);
imshow(grayImage, []);
title(‘Original Grayscale Image’);
impixelinfo;
% Crop image
% grayImage = imcrop(grayImage);
Img = imcrop(grayImage,[670 60 800 500]);
% Update size.
[rows, columns, numberOfColorChannels] = size(Img);
%——————————————————————————————————–
% SEGMENTATION OF IMAGE
% Get a binary image
mask = Img < 22; %imbinarize(grayImage);
% Display the mask.
subplot(2, 3, 4);
imshow(mask, []);
impixelinfo;
title(‘Initial Binary Image’);
impixelinfo;
% Fill interior holes.
mask = imfill(mask, ‘holes’);
% Get rid of particles smaller than 10000 in size
mask = bwareaopen(mask,10000);
subplot(2, 3, 5);
imshow(mask, []);
impixelinfo;
title(‘Final Binary Image’);
impixelinfo;
% Get boundaries
boundaries = bwboundaries(mask);
subplot(2, 3, 6);
imshow(grayImage); % Show cropped image again.
hold on;
for k = 1 : length(boundaries)
thisBoundary = boundaries{k};
x = thisBoundary(:, 2);
y = thisBoundary(:, 1);
plot(x, y, ‘r-‘, ‘LineWidth’, 2);
end
%Specifing limits to get rid of the outer boundary
xlim([5 500]);
ylim([5 500]);
title(‘Image With Boundaries’); Hi,
I have to trace the boundaries in the image (attached original image).
I have to trace only one boundary as indicated in the image.
I tried this for only one image, how can I do this for number of images?
Waiting for a kind response.
Regards
Tayyaba
grayImage = imread(‘0002.tif’);
[rows, columns, numberOfColorChannels] = size(grayImage);
if numberOfColorChannels > 1
grayImage = rgb2gray(grayImage);
end
% Display the image.
subplot(2, 3, 1);
imshow(grayImage, []);
title(‘Original Grayscale Image’);
impixelinfo;
% Crop image
% grayImage = imcrop(grayImage);
Img = imcrop(grayImage,[670 60 800 500]);
% Update size.
[rows, columns, numberOfColorChannels] = size(Img);
%——————————————————————————————————–
% SEGMENTATION OF IMAGE
% Get a binary image
mask = Img < 22; %imbinarize(grayImage);
% Display the mask.
subplot(2, 3, 4);
imshow(mask, []);
impixelinfo;
title(‘Initial Binary Image’);
impixelinfo;
% Fill interior holes.
mask = imfill(mask, ‘holes’);
% Get rid of particles smaller than 10000 in size
mask = bwareaopen(mask,10000);
subplot(2, 3, 5);
imshow(mask, []);
impixelinfo;
title(‘Final Binary Image’);
impixelinfo;
% Get boundaries
boundaries = bwboundaries(mask);
subplot(2, 3, 6);
imshow(grayImage); % Show cropped image again.
hold on;
for k = 1 : length(boundaries)
thisBoundary = boundaries{k};
x = thisBoundary(:, 2);
y = thisBoundary(:, 1);
plot(x, y, ‘r-‘, ‘LineWidth’, 2);
end
%Specifing limits to get rid of the outer boundary
xlim([5 500]);
ylim([5 500]);
title(‘Image With Boundaries’); image processing, faq, process a sequence of files MATLAB Answers — New Questions