From: ImageAnalyst on
edge() will give you boundaries. If you don't like that, try
bwperim() or bwboundaries(). If you don't like those, see my previous
answer.
From: snehal d on
ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <54d784cf-2512-4f29-9403-66fbaff7bff8(a)y17g2000yqd.googlegroups.com>...
> edge() will give you boundaries. If you don't like that, try
> bwperim() or bwboundaries(). If you don't like those, see my previous
> answer.


[i,j]=find(ero==1);
c=max([i,j]);
d=min([i,j]);
am a beginer plz help me to plot a rectangle using the above max and min points..
From: ImageAnalyst on
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
clear all; % Erase all existing variables.
workspace; % Make sure the workspace panel is showing.
fontSize = 18;

% Read in standard MATLAB demo image.
grayImage = imread('moon.tif');
subplot(2, 2, 1);
imshow(grayImage, []);
title('Original Grayscale UINT8 Image');
set(gcf, 'Position', get(0,'Screensize')); % Maximize figure.

thresholdLevel = graythresh(grayImage);
binaryImage = grayImage > thresholdLevel * 255;
subplot(2, 2, 2);
imshow(binaryImage, []);
title('Binary Image');

horizontalProfile =max(binaryImage, [], 1);
x1 = find(horizontalProfile, 1, 'first');
x2 = find(horizontalProfile, 1, 'last');
verticalProfile =max(binaryImage, [], 2);
y1 = find(verticalProfile, 1, 'first');
y2 = find(verticalProfile, 1, 'last');
boxX = [x1 x2 x2 x1 x1];
boxY = [y1 y1 y2 y2 y1];

subplot(2, 2, 3);
imshow(grayImage, []);
hold on;
plot(boxX, boxY, 'r-');
title('Gray Image with Box');

subplot(2, 2, 4);
imshow(binaryImage, []);
hold on;
plot(boxX, boxY, 'r-');
title('Binary Image with Box');
From: snehal d on
ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <5a4a55ff-8805-4881-bf59-d799b6940691(a)i37g2000yqn.googlegroups.com>...
> clc; % Clear the command window.
> close all; % Close all figures (except those of imtool.)
> clear all; % Erase all existing variables.
> workspace; % Make sure the workspace panel is showing.
> fontSize = 18;
>
> % Read in standard MATLAB demo image.
> grayImage = imread('moon.tif');
> subplot(2, 2, 1);
> imshow(grayImage, []);
> title('Original Grayscale UINT8 Image');
> set(gcf, 'Position', get(0,'Screensize')); % Maximize figure.
>
> thresholdLevel = graythresh(grayImage);
> binaryImage = grayImage > thresholdLevel * 255;
> subplot(2, 2, 2);
> imshow(binaryImage, []);
> title('Binary Image');
>
> horizontalProfile =max(binaryImage, [], 1);
> x1 = find(horizontalProfile, 1, 'first');
> x2 = find(horizontalProfile, 1, 'last');
> verticalProfile =max(binaryImage, [], 2);
> y1 = find(verticalProfile, 1, 'first');
> y2 = find(verticalProfile, 1, 'last');
> boxX = [x1 x2 x2 x1 x1];
> boxY = [y1 y1 y2 y2 y1];
>
> subplot(2, 2, 3);
> imshow(grayImage, []);
> hold on;
> plot(boxX, boxY, 'r-');
> title('Gray Image with Box');
>
> subplot(2, 2, 4);
> imshow(binaryImage, []);
> hold on;
> plot(boxX, boxY, 'r-');
> title('Binary Image with Box');


Thank you