From: M Ladderman on
Hi all,

Sorry to have to ask for your help again, I thought making the mask from the connected nodes I get from us his code I can create the mask I need. However this is not the case. I just want to fill the area that is enclosed by the lines drawn between the nodes and use that as a binary mask, but I cant find a way to do this :(

Thanks


ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <84aef331-bcd4-450e-b957-8f7b000a521e(a)u34g2000yqu.googlegroups.com>...
> On Apr 13, 8:12 pm, "EBS " <ericDOTsamp...(a)gmail.com> wrote:
> > IA, you give great advice but you should know better than to use 'clear all'! :)
> >
> > Using 'clear all' removes the compiled M-files from the cache, making MATLAB have to JIT compile them and slowing things down - and no one wants that! It also blows away any breakpoints that the user has set.
> >
> > Just plain old 'clear' is the command that you're looking for...
> >
> > Cheers
> ------------------------------------------------------------------------
> clear would work too, or "clear variables". The other stuff that gets
> blown away by adding "all" I'm probably not using anyway, but I just
> do it for simple demos to make sure I'm starting from as clean a slate
> as possible. That's what the Mathworks instructor taught me years ago
> in my training class so I just stuck with it. It's never been a
> problem for me. But you're right that if you wanted to keep functions
> that you ran previously stored in memory and wanted to be superfast
> when/if you call them again you wouldn't use all.
>
> I know the help says that it blows away break points, but it does
> not. I do it all the time. I just tried it again just now on both a
> simple script and a function. My breakpoint remained and it stopped
> there. I tried running it both from the green "Run" triangle, and by
> typing the script name and function name into the command prompt. No
> difference - it always stops. Clear all does not disable breakpoints,
> regardless of (and contrary to) what the help says.
From: ImageAnalyst on
I haven't had a chance to run the new code where you extracted the
polygonal envelope of the fish. Maybe you could post it (as I said,
my code was left in a non-working state). But anyway, once you have
that envelope, you can use poly2mask to create a binary mask and then
dot-multiply it by your original.

binaryMaskImage = poly2mask(yourCoordinates);
maskedGrayImage = grayImage .* uint8(binaryMaskImage ); % integer
types must match, eg both uint8 or both int32, etc.
From: M Ladderman on
Hi this is what I used (the code you describe) but what I get does not seem to be the same segmentatation

J = imread('_DSC5398.JPG');
red=J(:,:,1);
green=J(:,:,2);
blue=J(:,:,3);

medred=median(median(red));
medgreen=median(median(green));
medblue=median(median(blue));

I=(green+blue);
a=500;
b=900;
c=3600;
d=1200;
I = imcrop(I,[a b c d]);
%figure, imshow(I), title('original image');
[pixelCountsG GLs] = imhist(I);
pixelCountsG(256,:)=[];
[peakLocmax]=peakfinder(pixelCountsG,std(pixelCountsG),1);
cutoff=0.20*pixelCountsG(max(peakLocmax),:);
cutoffrgb=find(pixelCountsG<cutoff);
rows_to_remove = any(cutoffrgb >= max(peakLocmax), 2);
cutoffrgb(rows_to_remove,:) = [];

%[peakLocmin]=peakfinder(pixelCountsG,0.1*pixelCountsG(max(peakLocmax),:),-1);
%rows_to_remove = any(peakLocmin >= 200, 2);
%peakLocmin(rows_to_remove,:) = [];
%imhist(I);
%I=medfilt2(I,[5 5]); %median filtering
%figure, imshow(I), title('after median filtering');
%BW = edge(I);
%imshow(BW);
%thresholdValue = median(peakLocmin);

thresholdValuetop = max(cutoffrgb);

%binaryImage = (I > thresholdValue);
%figure, imshow(binaryImage), title('>');
binaryImage2 = (I < thresholdValuetop);
%figure, imshow(binaryImage2), title('<');

%binaryImagefinal = (binaryImage+binaryImage2-1);
%figure, imshow(binaryImagefinal), title('final');

%se = strel('disk',10);
%binaryImage2=imopen(binaryImage2,se);
%figure, imshow(binaryImage2), title('imopen');
BWnobord = imclearborder(binaryImage2, 4);
%figure, imshow(BWnobord), title('no border');
se = strel('disk',10);
BWnobord = imopen(BWnobord,se);

box=regionprops(double(BWnobord),'BoundingBox');
boxx=round(cat(1,box.BoundingBox));

length=regionprops(double(BWnobord),'MajorAxisLength');
length=round(cat(1,length.MajorAxisLength));
angle=regionprops(double(BWnobord),'Orientation');
angle=abs(round(cat(1,angle.Orientation)));

height=(1/4.5)*length+(sin(deg2rad(angle))*length);
boxx(1,4)=height;
boxx=boxx+[(a-100) (b-100) (0+100) (0+120)];

K = imcrop(J,boxx);
I=rgb2gray(K);
red=K(:,:,1);
green=K(:,:,2);
blue=K(:,:,3);
%I=green;
%figure, imshow(I);

k=20;

binaryImage = (green > (medgreen+k*4));
%figure, imshow(binaryImage), title('>');
binaryImage2 = (green < (medgreen-k*1.5));
%figure, imshow(binaryImage2), title('<');
binaryImagefinalgreen = (binaryImage+binaryImage2);
%figure, imshow(binaryImagefinalgreen), title('green');


binaryImage = (blue > (medblue+k*4));
%figure, imshow(binaryImage), title('>');
binaryImage2 = (blue < (medblue-k*1.5));
%figure, imshow(binaryImage2), title('<');
binaryImagefinalblue = (binaryImage+binaryImage2);
%figure, imshow(binaryImagefinalblue), title('blue');

binaryImage = (red > (medred+k*4));
%figure, imshow(binaryImage), title('>');
binaryImage2 = (red < (medred-k*1.5));
%figure, imshow(binaryImage2), title('<');
binaryImagefinalred = binaryImage2;
%figure, imshow(binaryImagefinalred), title('red');

FinalBinary=binaryImagefinalgreen+binaryImagefinalblue+binaryImagefinalred;
sizeBinary=size(FinalBinary);
sizeBinary=sizeBinary(:,1);
zero=zeros([sizeBinary 5],'double');
FinalBinary=[FinalBinary zero];
figure, imshow(FinalBinary);
FinalBinary = imclearborder(FinalBinary, 26);
figure, imshow(FinalBinary);

se = strel('disk',5);
closeBW = imclose(FinalBinary,se);
figure, imshow(closeBW);

closeBW = imfill(closeBW, 'holes');
figure, imshow(closeBW);

se = strel('disk',3);
closeBW = imopen(closeBW,se);
figure, imshow(closeBW);
closeBW=im2bw(closeBW);





% Get the perimeter.
perimeterImage = bwperim(closeBW);
subplot(2,2,2);
imshow(perimeterImage, []);

% Create a new axes for the alpha shapes result,
% since ashape() seems to want to automatically
% put results into the current axes object.
subplot(2,2,3);
set(gca,'YDir','reverse') % Flip upside down.

[y, x] = find(perimeterImage);
r=100;

% set(gca,'YDir','reverse') % Flip upside down.


p=ashape(x,y,r,'-g'); % <- do NOT plot...
ns=p.nshape; % <- # alpha shapes...
as=p.ashape; % <- CELL of indices ax/ay into p.x/p.y for alpha shapes ]1-ns[...
xc=p.x(as{1}).'; % <- ax of alpha shape #1 NOTE: transpose(!)...
yc=p.y(as{1}).';
line(xc,yc,'marker','s','color',[0,0,0]);


sizecloseBW=size(closeBW);
xx=xc.';
yy=yc.';
mask=poly2mask(xx(:,1),yy(:,1),sizecloseBW(1),sizecloseBW(2));


%I=medfilt2(I,[8 8]);
%BWs = edge(I,'canny');
%figure, imshow(BWs), title('binary gradient mask');
%se90 = strel('line', 4, 90);
%se0 = strel('line', 4, 0);
%BWsdil = imdilate(BWs, [se90 se0]);
%figure, imshow(BWsdil), title('dilated gradient mask');

%BWdfill = imfill(BWsdil, 'holes');
%figure, imshow(BWdfill), title('binary image with filled holes');

%se = strel('disk',5);
%closeBW = imclose(BWdfill,se);
%figure, imshow(closeBW);

%BWdfill = imfill(closeBW, 'holes');
%figure, imshow(BWdfill), title('binary image with filled holes');

%seD = strel('diamond',2);
%BWfinal = imerode(BWdfill,seD);
%figure, imshow(BWfinal), title('segmented image');

%nieuwe manier idee: meet de achtergrond door middel van median (het is het
%grootste stuk in het eerste picture, en trek dat dan van segmented stukje
%af om te thresholden. en dit kan ook voor elk kanaal gebeuren... R G en B

ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <9b276c80-619e-4b77-8b19-f0bf8bf0d6f1(a)y14g2000yqm.googlegroups.com>...
> I haven't had a chance to run the new code where you extracted the
> polygonal envelope of the fish. Maybe you could post it (as I said,
> my code was left in a non-working state). But anyway, once you have
> that envelope, you can use poly2mask to create a binary mask and then
> dot-multiply it by your original.
>
> binaryMaskImage = poly2mask(yourCoordinates);
> maskedGrayImage = grayImage .* uint8(binaryMaskImage ); % integer
> types must match, eg both uint8 or both int32, etc.
From: M Ladderman on
I guess this is because the polygon drawn, draws some lines that are not the shortest lines to connect the nodes as are drawn when you use line as suggested by us. But from this line part it must be possible to mask this right?

"M Ladderman" <mirresimons(a)gmail.com> wrote in message <hq4ecc$71q$1(a)fred.mathworks.com>...
> Hi this is what I used (the code you describe) but what I get does not seem to be the same segmentatation
>
> J = imread('_DSC5398.JPG');
> red=J(:,:,1);
> green=J(:,:,2);
> blue=J(:,:,3);
>
> medred=median(median(red));
> medgreen=median(median(green));
> medblue=median(median(blue));
>
> I=(green+blue);
> a=500;
> b=900;
> c=3600;
> d=1200;
> I = imcrop(I,[a b c d]);
> %figure, imshow(I), title('original image');
> [pixelCountsG GLs] = imhist(I);
> pixelCountsG(256,:)=[];
> [peakLocmax]=peakfinder(pixelCountsG,std(pixelCountsG),1);
> cutoff=0.20*pixelCountsG(max(peakLocmax),:);
> cutoffrgb=find(pixelCountsG<cutoff);
> rows_to_remove = any(cutoffrgb >= max(peakLocmax), 2);
> cutoffrgb(rows_to_remove,:) = [];
>
> %[peakLocmin]=peakfinder(pixelCountsG,0.1*pixelCountsG(max(peakLocmax),:),-1);
> %rows_to_remove = any(peakLocmin >= 200, 2);
> %peakLocmin(rows_to_remove,:) = [];
> %imhist(I);
> %I=medfilt2(I,[5 5]); %median filtering
> %figure, imshow(I), title('after median filtering');
> %BW = edge(I);
> %imshow(BW);
> %thresholdValue = median(peakLocmin);
>
> thresholdValuetop = max(cutoffrgb);
>
> %binaryImage = (I > thresholdValue);
> %figure, imshow(binaryImage), title('>');
> binaryImage2 = (I < thresholdValuetop);
> %figure, imshow(binaryImage2), title('<');
>
> %binaryImagefinal = (binaryImage+binaryImage2-1);
> %figure, imshow(binaryImagefinal), title('final');
>
> %se = strel('disk',10);
> %binaryImage2=imopen(binaryImage2,se);
> %figure, imshow(binaryImage2), title('imopen');
> BWnobord = imclearborder(binaryImage2, 4);
> %figure, imshow(BWnobord), title('no border');
> se = strel('disk',10);
> BWnobord = imopen(BWnobord,se);
>
> box=regionprops(double(BWnobord),'BoundingBox');
> boxx=round(cat(1,box.BoundingBox));
>
> length=regionprops(double(BWnobord),'MajorAxisLength');
> length=round(cat(1,length.MajorAxisLength));
> angle=regionprops(double(BWnobord),'Orientation');
> angle=abs(round(cat(1,angle.Orientation)));
>
> height=(1/4.5)*length+(sin(deg2rad(angle))*length);
> boxx(1,4)=height;
> boxx=boxx+[(a-100) (b-100) (0+100) (0+120)];
>
> K = imcrop(J,boxx);
> I=rgb2gray(K);
> red=K(:,:,1);
> green=K(:,:,2);
> blue=K(:,:,3);
> %I=green;
> %figure, imshow(I);
>
> k=20;
>
> binaryImage = (green > (medgreen+k*4));
> %figure, imshow(binaryImage), title('>');
> binaryImage2 = (green < (medgreen-k*1.5));
> %figure, imshow(binaryImage2), title('<');
> binaryImagefinalgreen = (binaryImage+binaryImage2);
> %figure, imshow(binaryImagefinalgreen), title('green');
>
>
> binaryImage = (blue > (medblue+k*4));
> %figure, imshow(binaryImage), title('>');
> binaryImage2 = (blue < (medblue-k*1.5));
> %figure, imshow(binaryImage2), title('<');
> binaryImagefinalblue = (binaryImage+binaryImage2);
> %figure, imshow(binaryImagefinalblue), title('blue');
>
> binaryImage = (red > (medred+k*4));
> %figure, imshow(binaryImage), title('>');
> binaryImage2 = (red < (medred-k*1.5));
> %figure, imshow(binaryImage2), title('<');
> binaryImagefinalred = binaryImage2;
> %figure, imshow(binaryImagefinalred), title('red');
>
> FinalBinary=binaryImagefinalgreen+binaryImagefinalblue+binaryImagefinalred;
> sizeBinary=size(FinalBinary);
> sizeBinary=sizeBinary(:,1);
> zero=zeros([sizeBinary 5],'double');
> FinalBinary=[FinalBinary zero];
> figure, imshow(FinalBinary);
> FinalBinary = imclearborder(FinalBinary, 26);
> figure, imshow(FinalBinary);
>
> se = strel('disk',5);
> closeBW = imclose(FinalBinary,se);
> figure, imshow(closeBW);
>
> closeBW = imfill(closeBW, 'holes');
> figure, imshow(closeBW);
>
> se = strel('disk',3);
> closeBW = imopen(closeBW,se);
> figure, imshow(closeBW);
> closeBW=im2bw(closeBW);
>
>
>
>
>
> % Get the perimeter.
> perimeterImage = bwperim(closeBW);
> subplot(2,2,2);
> imshow(perimeterImage, []);
>
> % Create a new axes for the alpha shapes result,
> % since ashape() seems to want to automatically
> % put results into the current axes object.
> subplot(2,2,3);
> set(gca,'YDir','reverse') % Flip upside down.
>
> [y, x] = find(perimeterImage);
> r=100;
>
> % set(gca,'YDir','reverse') % Flip upside down.
>
>
> p=ashape(x,y,r,'-g'); % <- do NOT plot...
> ns=p.nshape; % <- # alpha shapes...
> as=p.ashape; % <- CELL of indices ax/ay into p.x/p.y for alpha shapes ]1-ns[...
> xc=p.x(as{1}).'; % <- ax of alpha shape #1 NOTE: transpose(!)...
> yc=p.y(as{1}).';
> line(xc,yc,'marker','s','color',[0,0,0]);
>
>
> sizecloseBW=size(closeBW);
> xx=xc.';
> yy=yc.';
> mask=poly2mask(xx(:,1),yy(:,1),sizecloseBW(1),sizecloseBW(2));
>
>
> %I=medfilt2(I,[8 8]);
> %BWs = edge(I,'canny');
> %figure, imshow(BWs), title('binary gradient mask');
> %se90 = strel('line', 4, 90);
> %se0 = strel('line', 4, 0);
> %BWsdil = imdilate(BWs, [se90 se0]);
> %figure, imshow(BWsdil), title('dilated gradient mask');
>
> %BWdfill = imfill(BWsdil, 'holes');
> %figure, imshow(BWdfill), title('binary image with filled holes');
>
> %se = strel('disk',5);
> %closeBW = imclose(BWdfill,se);
> %figure, imshow(closeBW);
>
> %BWdfill = imfill(closeBW, 'holes');
> %figure, imshow(BWdfill), title('binary image with filled holes');
>
> %seD = strel('diamond',2);
> %BWfinal = imerode(BWdfill,seD);
> %figure, imshow(BWfinal), title('segmented image');
>
> %nieuwe manier idee: meet de achtergrond door middel van median (het is het
> %grootste stuk in het eerste picture, en trek dat dan van segmented stukje
> %af om te thresholden. en dit kan ook voor elk kanaal gebeuren... R G en B
>
> ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <9b276c80-619e-4b77-8b19-f0bf8bf0d6f1(a)y14g2000yqm.googlegroups.com>...
> > I haven't had a chance to run the new code where you extracted the
> > polygonal envelope of the fish. Maybe you could post it (as I said,
> > my code was left in a non-working state). But anyway, once you have
> > that envelope, you can use poly2mask to create a binary mask and then
> > dot-multiply it by your original.
> >
> > binaryMaskImage = poly2mask(yourCoordinates);
> > maskedGrayImage = grayImage .* uint8(binaryMaskImage ); % integer
> > types must match, eg both uint8 or both int32, etc.
From: M Ladderman on
Hi all,

I have tried to figure it out myself but with little luck. The line function returns a handle for each line which is the length or so? But no angles, so I do not know how to use this to convert this to a binary or plot it onto my earlier binary image. The polygon option is not the way to go I guess because the segmentation seems to be worse.

L

"M Ladderman" <mirresimons(a)gmail.com> wrote in message <hq7vdq$a32$1(a)fred.mathworks.com>...
> I guess this is because the polygon drawn, draws some lines that are not the shortest lines to connect the nodes as are drawn when you use line as suggested by us. But from this line part it must be possible to mask this right?
>
> "M Ladderman" <mirresimons(a)gmail.com> wrote in message <hq4ecc$71q$1(a)fred.mathworks.com>...
> > Hi this is what I used (the code you describe) but what I get does not seem to be the same segmentatation
> >
> > J = imread('_DSC5398.JPG');
> > red=J(:,:,1);
> > green=J(:,:,2);
> > blue=J(:,:,3);
> >
> > medred=median(median(red));
> > medgreen=median(median(green));
> > medblue=median(median(blue));
> >
> > I=(green+blue);
> > a=500;
> > b=900;
> > c=3600;
> > d=1200;
> > I = imcrop(I,[a b c d]);
> > %figure, imshow(I), title('original image');
> > [pixelCountsG GLs] = imhist(I);
> > pixelCountsG(256,:)=[];
> > [peakLocmax]=peakfinder(pixelCountsG,std(pixelCountsG),1);
> > cutoff=0.20*pixelCountsG(max(peakLocmax),:);
> > cutoffrgb=find(pixelCountsG<cutoff);
> > rows_to_remove = any(cutoffrgb >= max(peakLocmax), 2);
> > cutoffrgb(rows_to_remove,:) = [];
> >
> > %[peakLocmin]=peakfinder(pixelCountsG,0.1*pixelCountsG(max(peakLocmax),:),-1);
> > %rows_to_remove = any(peakLocmin >= 200, 2);
> > %peakLocmin(rows_to_remove,:) = [];
> > %imhist(I);
> > %I=medfilt2(I,[5 5]); %median filtering
> > %figure, imshow(I), title('after median filtering');
> > %BW = edge(I);
> > %imshow(BW);
> > %thresholdValue = median(peakLocmin);
> >
> > thresholdValuetop = max(cutoffrgb);
> >
> > %binaryImage = (I > thresholdValue);
> > %figure, imshow(binaryImage), title('>');
> > binaryImage2 = (I < thresholdValuetop);
> > %figure, imshow(binaryImage2), title('<');
> >
> > %binaryImagefinal = (binaryImage+binaryImage2-1);
> > %figure, imshow(binaryImagefinal), title('final');
> >
> > %se = strel('disk',10);
> > %binaryImage2=imopen(binaryImage2,se);
> > %figure, imshow(binaryImage2), title('imopen');
> > BWnobord = imclearborder(binaryImage2, 4);
> > %figure, imshow(BWnobord), title('no border');
> > se = strel('disk',10);
> > BWnobord = imopen(BWnobord,se);
> >
> > box=regionprops(double(BWnobord),'BoundingBox');
> > boxx=round(cat(1,box.BoundingBox));
> >
> > length=regionprops(double(BWnobord),'MajorAxisLength');
> > length=round(cat(1,length.MajorAxisLength));
> > angle=regionprops(double(BWnobord),'Orientation');
> > angle=abs(round(cat(1,angle.Orientation)));
> >
> > height=(1/4.5)*length+(sin(deg2rad(angle))*length);
> > boxx(1,4)=height;
> > boxx=boxx+[(a-100) (b-100) (0+100) (0+120)];
> >
> > K = imcrop(J,boxx);
> > I=rgb2gray(K);
> > red=K(:,:,1);
> > green=K(:,:,2);
> > blue=K(:,:,3);
> > %I=green;
> > %figure, imshow(I);
> >
> > k=20;
> >
> > binaryImage = (green > (medgreen+k*4));
> > %figure, imshow(binaryImage), title('>');
> > binaryImage2 = (green < (medgreen-k*1.5));
> > %figure, imshow(binaryImage2), title('<');
> > binaryImagefinalgreen = (binaryImage+binaryImage2);
> > %figure, imshow(binaryImagefinalgreen), title('green');
> >
> >
> > binaryImage = (blue > (medblue+k*4));
> > %figure, imshow(binaryImage), title('>');
> > binaryImage2 = (blue < (medblue-k*1.5));
> > %figure, imshow(binaryImage2), title('<');
> > binaryImagefinalblue = (binaryImage+binaryImage2);
> > %figure, imshow(binaryImagefinalblue), title('blue');
> >
> > binaryImage = (red > (medred+k*4));
> > %figure, imshow(binaryImage), title('>');
> > binaryImage2 = (red < (medred-k*1.5));
> > %figure, imshow(binaryImage2), title('<');
> > binaryImagefinalred = binaryImage2;
> > %figure, imshow(binaryImagefinalred), title('red');
> >
> > FinalBinary=binaryImagefinalgreen+binaryImagefinalblue+binaryImagefinalred;
> > sizeBinary=size(FinalBinary);
> > sizeBinary=sizeBinary(:,1);
> > zero=zeros([sizeBinary 5],'double');
> > FinalBinary=[FinalBinary zero];
> > figure, imshow(FinalBinary);
> > FinalBinary = imclearborder(FinalBinary, 26);
> > figure, imshow(FinalBinary);
> >
> > se = strel('disk',5);
> > closeBW = imclose(FinalBinary,se);
> > figure, imshow(closeBW);
> >
> > closeBW = imfill(closeBW, 'holes');
> > figure, imshow(closeBW);
> >
> > se = strel('disk',3);
> > closeBW = imopen(closeBW,se);
> > figure, imshow(closeBW);
> > closeBW=im2bw(closeBW);
> >
> >
> >
> >
> >
> > % Get the perimeter.
> > perimeterImage = bwperim(closeBW);
> > subplot(2,2,2);
> > imshow(perimeterImage, []);
> >
> > % Create a new axes for the alpha shapes result,
> > % since ashape() seems to want to automatically
> > % put results into the current axes object.
> > subplot(2,2,3);
> > set(gca,'YDir','reverse') % Flip upside down.
> >
> > [y, x] = find(perimeterImage);
> > r=100;
> >
> > % set(gca,'YDir','reverse') % Flip upside down.
> >
> >
> > p=ashape(x,y,r,'-g'); % <- do NOT plot...
> > ns=p.nshape; % <- # alpha shapes...
> > as=p.ashape; % <- CELL of indices ax/ay into p.x/p.y for alpha shapes ]1-ns[...
> > xc=p.x(as{1}).'; % <- ax of alpha shape #1 NOTE: transpose(!)...
> > yc=p.y(as{1}).';
> > line(xc,yc,'marker','s','color',[0,0,0]);
> >
> >
> > sizecloseBW=size(closeBW);
> > xx=xc.';
> > yy=yc.';
> > mask=poly2mask(xx(:,1),yy(:,1),sizecloseBW(1),sizecloseBW(2));
> >
> >
> > %I=medfilt2(I,[8 8]);
> > %BWs = edge(I,'canny');
> > %figure, imshow(BWs), title('binary gradient mask');
> > %se90 = strel('line', 4, 90);
> > %se0 = strel('line', 4, 0);
> > %BWsdil = imdilate(BWs, [se90 se0]);
> > %figure, imshow(BWsdil), title('dilated gradient mask');
> >
> > %BWdfill = imfill(BWsdil, 'holes');
> > %figure, imshow(BWdfill), title('binary image with filled holes');
> >
> > %se = strel('disk',5);
> > %closeBW = imclose(BWdfill,se);
> > %figure, imshow(closeBW);
> >
> > %BWdfill = imfill(closeBW, 'holes');
> > %figure, imshow(BWdfill), title('binary image with filled holes');
> >
> > %seD = strel('diamond',2);
> > %BWfinal = imerode(BWdfill,seD);
> > %figure, imshow(BWfinal), title('segmented image');
> >
> > %nieuwe manier idee: meet de achtergrond door middel van median (het is het
> > %grootste stuk in het eerste picture, en trek dat dan van segmented stukje
> > %af om te thresholden. en dit kan ook voor elk kanaal gebeuren... R G en B
> >
> > ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <9b276c80-619e-4b77-8b19-f0bf8bf0d6f1(a)y14g2000yqm.googlegroups.com>...
> > > I haven't had a chance to run the new code where you extracted the
> > > polygonal envelope of the fish. Maybe you could post it (as I said,
> > > my code was left in a non-working state). But anyway, once you have
> > > that envelope, you can use poly2mask to create a binary mask and then
> > > dot-multiply it by your original.
> > >
> > > binaryMaskImage = poly2mask(yourCoordinates);
> > > maskedGrayImage = grayImage .* uint8(binaryMaskImage ); % integer
> > > types must match, eg both uint8 or both int32, etc.
First  |  Prev  |  Next  |  Last
Pages: 1 2 3 4 5 6
Prev: Problem with refreshing figure
Next: problem