From: marlina on
Hi all,

here is my code:

clc;%close all;%clear all;
I = imread('.\image\picture6a.jpg');

Igray = rgb2gray(I); % convert image to grayscale
Imul=immultiply(Igray,1.0); % do some contrast balancing

Inoise = imnoise(Imul,'salt & pepper',0.01);
Imed = medfilt2(Inoise,[3 3]); % noise distortion using median filter

Iedge=edge(Imed, 'canny',[0.09 0.6],1.5); % edge detection using canny
figure(1),imshow(Iedge)

figure(2),imshow(Imed,[]); %boundary tracing
s=size(Iedge);
for row = 2:5:s(1)
for col=1:s(2)
if Iedge(row,col),
break;
end
end

contour = bwtraceboundary(Iedge, [row, col], 'S', 8, inf,...
'counterclockwise');
if(~isempty(contour))
hold on;
plot(contour(:,2),contour(:,1),'g','LineWidth',2);
hold on;
plot(col, row,'gx','LineWidth',2);

end
end

From figure (1)---it will show edge of the hand (bw image- only edge of the hand is in white color, others is black including foreground of the hand)
figure (2)---it will show detection of edge at grayscale image

So, my question is how i am going to translate edge detection image from grayscale image into picture 2 (where the background is black) and use edge detection from figure 2 as a reference.

summary of my question: background is black and hand region is in grayscale

Thank you...i really need the answer....plzzz
From: Sean on
"marlina " <marlinayakno(a)gmail.com> wrote in message <i4002l$ib3$1(a)fred.mathworks.com>...
> Hi all,
>
> here is my code:
>
> clc;%close all;%clear all;
> I = imread('.\image\picture6a.jpg');
>
> Igray = rgb2gray(I); % convert image to grayscale
> Imul=immultiply(Igray,1.0); % do some contrast balancing
>
> Inoise = imnoise(Imul,'salt & pepper',0.01);
> Imed = medfilt2(Inoise,[3 3]); % noise distortion using median filter
>
> Iedge=edge(Imed, 'canny',[0.09 0.6],1.5); % edge detection using canny
> figure(1),imshow(Iedge)
>
> figure(2),imshow(Imed,[]); %boundary tracing
> s=size(Iedge);
> for row = 2:5:s(1)
> for col=1:s(2)
> if Iedge(row,col),
> break;
> end
> end
>
> contour = bwtraceboundary(Iedge, [row, col], 'S', 8, inf,...
> 'counterclockwise');
> if(~isempty(contour))
> hold on;
> plot(contour(:,2),contour(:,1),'g','LineWidth',2);
> hold on;
> plot(col, row,'gx','LineWidth',2);
>
> end
> end
>
> From figure (1)---it will show edge of the hand (bw image- only edge of the hand is in white color, others is black including foreground of the hand)
> figure (2)---it will show detection of edge at grayscale image
>
> So, my question is how i am going to translate edge detection image from grayscale image into picture 2 (where the background is black) and use edge detection from figure 2 as a reference.
>
> summary of my question: background is black and hand region is in grayscale
>
> Thank you...i really need the answer....plzzz

%%%
So your gray image is uint8, that means white is intensity 255:
Igray(Iedge) = 255;
From: marlina on
Hi Sean,

Thank you for your suggestion....but that's not my aim.
from your code : Igray(Iedge) = 255;
the outline of the hand edge from figure 1(canny edge detection) will be translate into into grayscale image.

my objective ito translate grayscale image of hand into figure 2 (canny edge detection)...its look like you crop the hand image form grayscale image into figure 2....so the hand image is in grayscale and background is black. I hope you can understand my objective.

Thank you so much...Looking forward for any suggestion..


Marlina
 | 
Pages: 1
Prev: vector computation
Next: Digital Image Processing