From: us on
"M Ladderman" <mirresimons(a)gmail.com> wrote in message <hot214$21p$1(a)fred.mathworks.com>...
> "M Ladderman" <mirresimons(a)gmail.com> wrote in message <hot13j$fm7$1(a)fred.mathworks.com>...
> > That looks promising, I will try and implement it. So I can set more or less how flexible the convex hull is, that is would I think I need. I had tried it a while ago this code but I did not succeed in implementing it. I will try again. It will work with binary images? Thanks!
> >
> > ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <88de8fa6-05f5-46f7-8707-0a2c0f29f205(a)e7g2000yqf.googlegroups.com>...
> > > I think this might be a good situation for alpha shapes. us, don't
> > > you agree? us has uploaded an alpha shape program to the File
> > > Exchange:
> > > http://www.mathworks.com/matlabcentral/fileexchange/6760-ashape-a-pedestrian-alpha-shape-extractor
> > >
> > > It's sort of like a flexible convex hull - one that can more or less
> > > follow nooks and crannies rather than being strictly convex.

> Stupid question maybe but I cannot remember how to get x,y from a binary image (so two vectors that describe where the 1 of the binary image are at), to use that for the input in Ashape.
>

firstly: thanks, IA, to allude to the pedestrian ashaper(!)...

one of the solutions

img=[
0 0 0 0 0 0 0
0 0 0 1 0 0 0
0 0 1 1 1 0 0
0 1 1 1 1 1 0
0 0 1 1 1 0 0
0 0 0 1 0 0 0
0 0 0 0 0 0 0
];
bp=bwperim(img);
[y,x]=find(bp);
ashape(x,y,1); % <- select your ALPHA...

NOTE:
- if you use r2010a, there will be an annoying warning message due to the fact that
DELAUNAY now has a different syntax...
- i will change this asap...
- sorry for this...

us
From: ImageAnalyst on
us
I thought this fish image wold be a good one for me to practice on
with your ashaper. I got this far but something's not right. I
thought I'd try something quick and dirty but I guess I need to really
dig into the options to figure it out. I need to get going now -
maybe I can pick it up later in the day.

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 and crop image.
filename = 'C:\Documents and Settings\username\My Documents\Temporary
stuff\fishexample.jpg';
imageArray = imread(filename);
% Convert to grayscale.
imageArray = imageArray(:,:,1);
% Crop off the border.
imageArray = imcrop(imageArray, [145 27 1127 425]);
% convert to binary.
imageArray = imageArray > 128;
subplot(2,2,1);
imshow(imageArray, []);
title('Original Image', 'FontSize', fontSize);
set(gcf, 'Position', get(0,'Screensize')); % Maximize figure.

% Get the perimeter.
perimeterImage = bwperim(imageArray);
subplot(2,2,2);
imshow(perimeterImage, []);
title('Perimeter Image', 'FontSize', fontSize);

% 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.
title('Alpha Shape Image', 'FontSize', fontSize);
[y, x] = find(perimeterImage);
aslibStructure = ashape(x, y, 2.5); % <- select your ALPHA...

subplot(2,2,4);
% set(gca,'YDir','reverse') % Flip upside down.
plot(aslibStructure.x, aslibStructure.y);
axis 'equal';
title('Alpha Shape Image2', 'FontSize', fontSize);

From: M Ladderman on
Hi,

I have been working on this with same adjustments to the alpha but, with very low alphas I still get a small (but significant) hole in the belly that is not covered. Any ideas on how to improve this?

Thanks!

Mirre


ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <f2d1b2ac-4e40-4f6c-83ed-3ff92fb98eb4(a)b30g2000yqd.googlegroups.com>...
> us
> I thought this fish image wold be a good one for me to practice on
> with your ashaper. I got this far but something's not right. I
> thought I'd try something quick and dirty but I guess I need to really
> dig into the options to figure it out. I need to get going now -
> maybe I can pick it up later in the day.
>
> 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 and crop image.
> filename = 'C:\Documents and Settings\username\My Documents\Temporary
> stuff\fishexample.jpg';
> imageArray = imread(filename);
> % Convert to grayscale.
> imageArray = imageArray(:,:,1);
> % Crop off the border.
> imageArray = imcrop(imageArray, [145 27 1127 425]);
> % convert to binary.
> imageArray = imageArray > 128;
> subplot(2,2,1);
> imshow(imageArray, []);
> title('Original Image', 'FontSize', fontSize);
> set(gcf, 'Position', get(0,'Screensize')); % Maximize figure.
>
> % Get the perimeter.
> perimeterImage = bwperim(imageArray);
> subplot(2,2,2);
> imshow(perimeterImage, []);
> title('Perimeter Image', 'FontSize', fontSize);
>
> % 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.
> title('Alpha Shape Image', 'FontSize', fontSize);
> [y, x] = find(perimeterImage);
> aslibStructure = ashape(x, y, 2.5); % <- select your ALPHA...
>
> subplot(2,2,4);
> % set(gca,'YDir','reverse') % Flip upside down.
> plot(aslibStructure.x, aslibStructure.y);
> axis 'equal';
> title('Alpha Shape Image2', 'FontSize', fontSize);
From: ImageAnalyst on
Not from me - I haven't had a chance to return to looking at this.
Maybe if you've taken my code further, you can post it and us can help
us out (no pun intended)
From: M Ladderman on
Hi,

Stupid me I tried lower alphas, which result of course in smaller structuring disks. Stupid sorry. So I got my alpha up and get a nice segmentation image from ashape, I want to use the x and y now to get them connected in the way ashape does it. In ashape my whole fish is enclosed by connected dots (by lines). But when I use plot there is still a part missing probably because the polygon plot draws is not the same as ashape displays?

I hope this is more or less clear what I mean.

Cheers


ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <aa8ee488-d330-4ad2-97a3-7807707b857c(a)h27g2000yqm.googlegroups.com>...
> Not from me - I haven't had a chance to return to looking at this.
> Maybe if you've taken my code further, you can post it and us can help
> us out (no pun intended)
First  |  Prev  |  Next  |  Last
Pages: 1 2 3 4 5 6
Prev: Problem with refreshing figure
Next: problem