Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Tessellation of irregular shapes

Subject: Tessellation of irregular shapes

From: behzad majidi

Date: 1 Feb, 2011 23:06:03

Message: 1 of 18

Hi everybody,

I'm gonna use Discrete Element Modeling of particulate material with irregular shaped particles. I have to convert my particles to DEM models by tessellating irregular shapes with circles. The model is gonna be 2D.
How can I use matlab to do so? Circles MAY overlap.

Subject: Tessellation of irregular shapes

From: ImageAnalyst

Date: 1 Feb, 2011 23:41:12

Message: 2 of 18

On Feb 1, 6:06 pm, "behzad majidi" <behzad.maj...@gmail.com> wrote:
> Hi everybody,
>
> I'm gonna use Discrete Element Modeling of particulate material with irregular shaped particles. I have to convert my particles to DEM models by tessellating irregular shapes with circles. The model is gonna be 2D.
> How can I use matlab to do so? Circles MAY overlap.

------------------------------------------------
How many circles do you want to cover your shape? I don't know about
"Discrete Element Modeling of particulate material" but if you want to
figure out how many circles it takes to cover a shape, you can use
granulometry
http://en.wikipedia.org/wiki/Granulometry_%28morphology%29
It's a morphological imaging way of approaching it. But if you allow
overlapping circles, then how about just two circles, or just one
giant circle for that matter? Why do you need multiple circles? Are
the circles not allowed to extend beyond the outer boundary of the
shape?
ImageAnalyst

Subject: Tessellation of irregular shapes

From: behzad majidi

Date: 6 Mar, 2011 22:41:04

Message: 3 of 18

Hey,

Number of circles should be as low as possible.
as for "why I need to do so?" because I have to model some irregular shapes by assembly of circles. It will be an input to sort of simulations.
Yes, circles are not allowed to extend beyond the boundary of the shape. The aim of this work is to model the shape of an irregular-shaped particle.
So I need several overlapped circles with different sizes to meet the minimum number of circles condition and also the best representation of the shape.
tnx

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <49d829a5-1598-48ca-a0cc-d803639a9cee@r19g2000prm.googlegroups.com>...
> On Feb 1, 6:06 pm, "behzad majidi" <behzad.maj...@gmail.com> wrote:
> > Hi everybody,
> >
> > I'm gonna use Discrete Element Modeling of particulate material with irregular shaped particles. I have to convert my particles to DEM models by tessellating irregular shapes with circles. The model is gonna be 2D.
> > How can I use matlab to do so? Circles MAY overlap.
>
> ------------------------------------------------
> How many circles do you want to cover your shape? I don't know about
> "Discrete Element Modeling of particulate material" but if you want to
> figure out how many circles it takes to cover a shape, you can use
> granulometry
> http://en.wikipedia.org/wiki/Granulometry_%28morphology%29
> It's a morphological imaging way of approaching it. But if you allow
> overlapping circles, then how about just two circles, or just one
> giant circle for that matter? Why do you need multiple circles? Are
> the circles not allowed to extend beyond the outer boundary of the
> shape?
> ImageAnalyst

Subject: Tessellation of irregular shapes

From: ImageAnalyst

Date: 6 Mar, 2011 23:07:17

Message: 4 of 18

If the circles may overlap, but not extend past the boundary of the
irregularly shaped object, then the problem is trivial. Just use the
Euclidean Distance Transform (EDT). The value of every pixel is the
radius of the circle that should be placed at that pixel location.
Very easy one of two line solution with bwdist, however you'll have
lots of circles that will overlap.

If you want fewer circles, then loop and take the biggest EDT at each
iteration which represents the single biggest circle for that
iteration. Then exclude that circle (mask it out against the original
binary image) and do it again on what's left. Keep going until you
have no more pixels to pick from in your original EDT image.

And no, I don't have code for it but it should be easy to program up.
Do you have the Image Processing Toolbox?

edtImage = bwdist(binaryImage);
maskedEdtImage2 = edtImage;
do
  % Find largest value in maskedEdtImage2
  % If largest value is smaller than you're interested in, break out
of loop.
  % Erase a circle with the radius of that, and at that location from
maskedEdtImage2
  % Store circle (x,y,radius) in output array.
while there are pixels left in maskedEdtImage2

I think something like that should work. Give it a try.

Subject: Tessellation of irregular shapes

From: ImageAnalyst

Date: 7 Mar, 2011 00:31:49

Message: 5 of 18

OK, it's pretty easy but in case you have trouble with your code,
compare it against my code:

% Demo to fill an irregular shape with circles.
% By Image Analyst.

% IMPORTANT: The newsreader may break long lines into multiple lines.
% Be sure to join any long lines that got split into multiple single
lines.
% These can be found by the red lines on the left side of your
% text editor, which indicate syntax errors, or else just run the
% code and it will stop at the split lines with an error.
% function fill_blob_with_circles()
clc; % Clear the command window.
close all; % Close all figures (except those of imtool.)
imtool close all; % Close all imtool figures.
clear; % Erase all existing variables.
workspace; % Make sure the workspace panel is showing.
fontSize = 14;

% Change the current folder to the folder of this m-file.
if(~isdeployed)
cd(fileparts(which(mfilename)));
end

% Check that user has the Image Processing Toolbox installed.
hasIPT = license('test', 'image_toolbox');
if ~hasIPT
% User does not have the toolbox installed.
message = sprintf('Sorry, but you do not seem to have the Image
Processing Toolbox.\nDo you want to try to continue anyway?');
reply = questdlg(message, 'Toolbox missing', 'Yes', 'No', 'Yes');
if strcmpi(reply, 'No')
% User said No, so exit.
return;
end
end

% Generate some sample data that we can get an irregular blob out of.
grayImage = peaks(256);
[imageRows imageCols] = size(grayImage);
% Display the original gray scale image.
subplot(2, 2, 1);
imshow(grayImage, []);
title('Original Grayscale Image', 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'Position', get(0,'Screensize'));
set(gcf,'name','Demo by ImageAnalyst','numbertitle','off')

% Binarize it to get an irregular shape.
binaryImage = grayImage > 1.4;
subplot(2, 2, 2);
imshow(binaryImage, []);
title('Binary Image', 'FontSize', fontSize);

edtImage = bwdist(~binaryImage);
maskedEdtImage2 = edtImage;
subplot(2, 2, 3);
imshow(edtImage, []);
title('EDT Image', 'FontSize', fontSize);
numCircles = 0;
subplot(2, 2, 2);
hold on;

% Set up some stopping parameters:
maxCirclesPerBlob = 30; % Some max number as a failsafe. Must be >=
1.
smallestAcceptableCircle = 2; % Must be >= 1;
keepGoing = true;

% Now do the loop over the EDT taking the largest point each time.
while keepGoing
% Find largest value remaining in maskedEdtImage2.
[row col] = find(maskedEdtImage2 == max(max(maskedEdtImage2)), 1,
'first');

% Erase a circle with the radius of that, and at that location from
maskedEdtImage2
% First we need to create a circle there.
% From the FAQ: Create a logical image of a circle with specified
% diameter, center, and image size.
% First create the image.
[columnsInImage rowsInImage] = meshgrid(1:imageCols, 1:imageRows);
% Next create the circle in the image.
centerX = col;
centerY = row;
radius = edtImage(row, col);
circlePixels = sqrt((rowsInImage - centerY).^2 ...
+ (columnsInImage - centerX).^2) <= radius;
% circlePixels is a 2D "logical" array.

% Erase these pixels from the masked EDT image.
maskedEdtImage2(circlePixels) = 0;
% Display the masked EDT image.
subplot(2, 2, 4);
hold on;
imshow(maskedEdtImage2, []);
title('Masked EDT Image', 'FontSize', fontSize);
drawnow;

% Increment the number of circles we found.
numCircles = numCircles + 1;

% Store circle (x,y,radius) in output array.
circleData(numCircles, 1) = row;
circleData(numCircles, 2) = col;
circleData(numCircles, 3) = radius;

% Print it out.
message = sprintf('Circle #%d, center at (%d, %d), with radius = %.2f
\n',...
numCircles, row, col, radius);

% Plot it over the binary image.
subplot(2, 2, 2);
rectangle('Position',[centerX-radius, centerY-radius, 2*radius,
2*radius],...
    'Curvature',[1,1], 'EdgeColor', 'r');

promptMessage = sprintf('%s\nDo you want to Continue processing,\nor
Cancel to abort processing?', message);
button = questdlg(promptMessage, 'Continue', 'Continue', 'Cancel',
'Continue');
if strcmp(button, 'Cancel')
break;
end

% Determine if we need to stop yet.
bigEnough = max(max(maskedEdtImage2)) > smallestAcceptableCircle;
pixelsRemain = nnz(maskedEdtImage2) > 0;
notTooManyCircles = numCircles < maxCirclesPerBlob;
keepGoing = bigEnough && pixelsRemain && notTooManyCircles;

% Let user know why we're quitting.
if ~bigEnough
message = sprintf('Quitting because circles are now too small (%.2f
pixels)', smallestAcceptableCircle);
elseif ~pixelsRemain
message = sprintf('Quitting because no more pxiels remain.');
elseif ~notTooManyCircles
message = sprintf('Quitting because we hit the max number of circles
(%d)', maxCirclesPerBlob);
end
if ~keepGoing
uiwait(msgbox(message));
end
end % while there are pixels left in maskedEdtImage2

% Display our results in the command window.
fprintf('X, Y, Radius\n');
disp(circleData);
message = sprintf('Demo done!\nCheck out the command window');
uiwait(msgbox(message));

Subject: Tessellation of irregular shapes

From: behzad majidi

Date: 7 Mar, 2011 18:26:21

Message: 6 of 18

hi, thanks a lot for sending the code.
But I tried it and it didn't work.


ImageAnalyst <imageanalyst@mailinator.com> wrote in message <5485ce61-b094-48a7-9bca-b2e20e813565@w6g2000vbo.googlegroups.com>...
> OK, it's pretty easy but in case you have trouble with your code,
> compare it against my code:
>
> % Demo to fill an irregular shape with circles.
> % By Image Analyst.
>
> % IMPORTANT: The newsreader may break long lines into multiple lines.
> % Be sure to join any long lines that got split into multiple single
> lines.
> % These can be found by the red lines on the left side of your
> % text editor, which indicate syntax errors, or else just run the
> % code and it will stop at the split lines with an error.
> % function fill_blob_with_circles()
> clc; % Clear the command window.
> close all; % Close all figures (except those of imtool.)
> imtool close all; % Close all imtool figures.
> clear; % Erase all existing variables.
> workspace; % Make sure the workspace panel is showing.
> fontSize = 14;
>
> % Change the current folder to the folder of this m-file.
> if(~isdeployed)
> cd(fileparts(which(mfilename)));
> end
>
> % Check that user has the Image Processing Toolbox installed.
> hasIPT = license('test', 'image_toolbox');
> if ~hasIPT
> % User does not have the toolbox installed.
> message = sprintf('Sorry, but you do not seem to have the Image
> Processing Toolbox.\nDo you want to try to continue anyway?');
> reply = questdlg(message, 'Toolbox missing', 'Yes', 'No', 'Yes');
> if strcmpi(reply, 'No')
> % User said No, so exit.
> return;
> end
> end
>
> % Generate some sample data that we can get an irregular blob out of.
> grayImage = peaks(256);
> [imageRows imageCols] = size(grayImage);
> % Display the original gray scale image.
> subplot(2, 2, 1);
> imshow(grayImage, []);
> title('Original Grayscale Image', 'FontSize', fontSize);
> % Enlarge figure to full screen.
> set(gcf, 'Position', get(0,'Screensize'));
> set(gcf,'name','Demo by ImageAnalyst','numbertitle','off')
>
> % Binarize it to get an irregular shape.
> binaryImage = grayImage > 1.4;
> subplot(2, 2, 2);
> imshow(binaryImage, []);
> title('Binary Image', 'FontSize', fontSize);
>
> edtImage = bwdist(~binaryImage);
> maskedEdtImage2 = edtImage;
> subplot(2, 2, 3);
> imshow(edtImage, []);
> title('EDT Image', 'FontSize', fontSize);
> numCircles = 0;
> subplot(2, 2, 2);
> hold on;
>
> % Set up some stopping parameters:
> maxCirclesPerBlob = 30; % Some max number as a failsafe. Must be >=
> 1.
> smallestAcceptableCircle = 2; % Must be >= 1;
> keepGoing = true;
>
> % Now do the loop over the EDT taking the largest point each time.
> while keepGoing
> % Find largest value remaining in maskedEdtImage2.
> [row col] = find(maskedEdtImage2 == max(max(maskedEdtImage2)), 1,
> 'first');
>
> % Erase a circle with the radius of that, and at that location from
> maskedEdtImage2
> % First we need to create a circle there.
> % From the FAQ: Create a logical image of a circle with specified
> % diameter, center, and image size.
> % First create the image.
> [columnsInImage rowsInImage] = meshgrid(1:imageCols, 1:imageRows);
> % Next create the circle in the image.
> centerX = col;
> centerY = row;
> radius = edtImage(row, col);
> circlePixels = sqrt((rowsInImage - centerY).^2 ...
> + (columnsInImage - centerX).^2) <= radius;
> % circlePixels is a 2D "logical" array.
>
> % Erase these pixels from the masked EDT image.
> maskedEdtImage2(circlePixels) = 0;
> % Display the masked EDT image.
> subplot(2, 2, 4);
> hold on;
> imshow(maskedEdtImage2, []);
> title('Masked EDT Image', 'FontSize', fontSize);
> drawnow;
>
> % Increment the number of circles we found.
> numCircles = numCircles + 1;
>
> % Store circle (x,y,radius) in output array.
> circleData(numCircles, 1) = row;
> circleData(numCircles, 2) = col;
> circleData(numCircles, 3) = radius;
>
> % Print it out.
> message = sprintf('Circle #%d, center at (%d, %d), with radius = %.2f
> \n',...
> numCircles, row, col, radius);
>
> % Plot it over the binary image.
> subplot(2, 2, 2);
> rectangle('Position',[centerX-radius, centerY-radius, 2*radius,
> 2*radius],...
> 'Curvature',[1,1], 'EdgeColor', 'r');
>
> promptMessage = sprintf('%s\nDo you want to Continue processing,\nor
> Cancel to abort processing?', message);
> button = questdlg(promptMessage, 'Continue', 'Continue', 'Cancel',
> 'Continue');
> if strcmp(button, 'Cancel')
> break;
> end
>
> % Determine if we need to stop yet.
> bigEnough = max(max(maskedEdtImage2)) > smallestAcceptableCircle;
> pixelsRemain = nnz(maskedEdtImage2) > 0;
> notTooManyCircles = numCircles < maxCirclesPerBlob;
> keepGoing = bigEnough && pixelsRemain && notTooManyCircles;
>
> % Let user know why we're quitting.
> if ~bigEnough
> message = sprintf('Quitting because circles are now too small (%.2f
> pixels)', smallestAcceptableCircle);
> elseif ~pixelsRemain
> message = sprintf('Quitting because no more pxiels remain.');
> elseif ~notTooManyCircles
> message = sprintf('Quitting because we hit the max number of circles
> (%d)', maxCirclesPerBlob);
> end
> if ~keepGoing
> uiwait(msgbox(message));
> end
> end % while there are pixels left in maskedEdtImage2
>
> % Display our results in the command window.
> fprintf('X, Y, Radius\n');
> disp(circleData);
> message = sprintf('Demo done!\nCheck out the command window');
> uiwait(msgbox(message));

Subject: Tessellation of irregular shapes

From: ImageAnalyst

Date: 7 Mar, 2011 19:38:05

Message: 7 of 18

On Mar 7, 1:26 pm, "behzad majidi" <behzad.maj...@gmail.com> wrote:
> hi, thanks a lot for sending the code.
> But I tried it and it didn't work.
---------------------------------------------------------------------
behzad majidi:
I just tried it on a different computer and it worked fine. I copied
and pasted from the newsgroup message, fixed lines broken into two
lines by the newsreader, and it worked perfectly. No problems
whatsoever. This was on a completely different computer than the one
I developed it on. So you did something wrong. Did you forget to
join the broken lines? If you want any more help on this you'll have
to give more information than "it didn't work" because it does work
for me.
ImageAnalyst

Subject: Tessellation of irregular shapes

From: behzad majidi

Date: 7 Mar, 2011 20:46:21

Message: 8 of 18

Hey,
I get the following message;

??? > % Demo to fill an irregular shape with circles.
    |
Error: Unexpected MATLAB operator.


Can I send you an example image to see the result?

Thanks so much,
Behzad

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <b6a64883-3d90-45b7-9e4d-3f05f806b473@o21g2000prh.googlegroups.com>...
> On Mar 7, 1:26 pm, "behzad majidi" <behzad.maj...@gmail.com> wrote:
> > hi, thanks a lot for sending the code.
> > But I tried it and it didn't work.
> ---------------------------------------------------------------------
> behzad majidi:
> I just tried it on a different computer and it worked fine. I copied
> and pasted from the newsgroup message, fixed lines broken into two
> lines by the newsreader, and it worked perfectly. No problems
> whatsoever. This was on a completely different computer than the one
> I developed it on. So you did something wrong. Did you forget to
> join the broken lines? If you want any more help on this you'll have
> to give more information than "it didn't work" because it does work
> for me.
> ImageAnalyst

Subject: Tessellation of irregular shapes

From: ImageAnalyst

Date: 7 Mar, 2011 21:18:21

Message: 9 of 18

On Mar 7, 3:46 pm, "behzad majidi" <behzad.maj...@gmail.com> wrote:
> Hey,
> I get the following message;
>
> ??? > % Demo to fill an irregular shape with circles.
>     |
> Error: Unexpected MATLAB operator.
-------------------------------------------------------------------------
It looks like you copied a reply and not the original code, hence the
">" on the line. Now, as a skilled MATLAB coder, I'm sure you know
that
> % Demo to fill an irregular shape with circles.
is not a valid comment line, and you can't just have ">" by itself on
a line followed by a comment, so what happened when you got rid of the
> from that line and every one of the subsequent lines?

You should really get it working - it's a cool demo even if I do say
so myself.

You can download the m-file here:
http://www.keepandshare.com/doc/2648627/circletess
If it asks for a password, it's imagesmatlab

Subject: Tessellation of irregular shapes

From: behzad majidi

Date: 8 Mar, 2011 02:58:04

Message: 10 of 18

Wow,
I tried it. It's perfect.
thanks so much.
But now how can I introduce different images to the code?
thanks

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <2eb748d8-7d4f-41d2-879c-910929c74b65@j35g2000prb.googlegroups.com>...
> On Mar 7, 3:46 pm, "behzad majidi" <behzad.maj...@gmail.com> wrote:
> > Hey,
> > I get the following message;
> >
> > ??? > % Demo to fill an irregular shape with circles.
> >     |
> > Error: Unexpected MATLAB operator.
> -------------------------------------------------------------------------
> It looks like you copied a reply and not the original code, hence the
> ">" on the line. Now, as a skilled MATLAB coder, I'm sure you know
> that
> > % Demo to fill an irregular shape with circles.
> is not a valid comment line, and you can't just have ">" by itself on
> a line followed by a comment, so what happened when you got rid of the
> > from that line and every one of the subsequent lines?
>
> You should really get it working - it's a cool demo even if I do say
> so myself.
>
> You can download the m-file here:
> http://www.keepandshare.com/doc/2648627/circletess
> If it asks for a password, it's imagesmatlab

Subject: Tessellation of irregular shapes

From: ImageAnalyst

Date: 8 Mar, 2011 03:15:16

Message: 11 of 18

Replace these lines:

% Generate some sample data that we can get an irregular blob out of.
grayImage = peaks(256);
[imageRows imageCols] = size(grayImage);
% Display the original gray scale image.
subplot(2, 2, 1);
imshow(grayImage, []);
title('Original Grayscale Image', 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'Position', get(0,'Screensize'));
set(gcf,'name','Demo by ImageAnalyst','numbertitle','off')

% Binarize it to get an irregular shape.
binaryImage = grayImage > 1.4;

with this line to read in your existing binary image:
binaryImage = imread(fullFileName);
Of course you know that you need to store the actual filename in the
variable fullFileName. And if your image is not already logical (or
at least an integer image with values of only 0 and 1), then you're
going to have to threshold it like I did.

Subject: Tessellation of irregular shapes

From: bob

Date: 8 Mar, 2011 04:54:04

Message: 12 of 18

now I'm getting such an error;

??? Error using ==> rectangle
Width and height must be > 0.

Error in ==> test16 at 75
        rectangle('Position',[centerX-radius, centerY-radius, 2*radius, 2*radius],...

it's my code;

a = imread('work.jpg');
grayImage = im2bw(a);
[imageRows imageCols] = size(grayImage);
% Display the original gray scale image.
subplot(2, 2, 1);
imshow(grayImage, []);
title('Original Grayscale Image', 'FontSize', fontSize);
% Enlarge figure to full screen.
set(gcf, 'Position', get(0,'Screensize'));
set(gcf,'name','Demo by ImageAnalyst','numbertitle','off')

% Binarize it to get an irregular shape.
binaryImage = grayImage > 1.4;
subplot(2, 2, 2);
imshow(binaryImage, []);
title('Binary Image', 'FontSize', fontSize);
.
.
.
.

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <5864cde9-84d3-48cf-baa5-354a3e8b1fb9@t16g2000vbi.googlegroups.com>...
> Replace these lines:
>
> % Generate some sample data that we can get an irregular blob out of.
> grayImage = peaks(256);
> [imageRows imageCols] = size(grayImage);
> % Display the original gray scale image.
> subplot(2, 2, 1);
> imshow(grayImage, []);
> title('Original Grayscale Image', 'FontSize', fontSize);
> % Enlarge figure to full screen.
> set(gcf, 'Position', get(0,'Screensize'));
> set(gcf,'name','Demo by ImageAnalyst','numbertitle','off')
>
> % Binarize it to get an irregular shape.
> binaryImage = grayImage > 1.4;
>
> with this line to read in your existing binary image:
> binaryImage = imread(fullFileName);
> Of course you know that you need to store the actual filename in the
> variable fullFileName. And if your image is not already logical (or
> at least an integer image with values of only 0 and 1), then you're
> going to have to threshold it like I did.

Subject: Tessellation of irregular shapes

From: bob

Date: 8 Mar, 2011 06:03:05

Message: 13 of 18

no no, I solved the problem and it works very well now.
Thanks a lot.

ImageAnalyst <imageanalyst@mailinator.com> wrote in message <5864cde9-84d3-48cf-baa5-354a3e8b1fb9@t16g2000vbi.googlegroups.com>...
> Replace these lines:
>
> % Generate some sample data that we can get an irregular blob out of.
> grayImage = peaks(256);
> [imageRows imageCols] = size(grayImage);
> % Display the original gray scale image.
> subplot(2, 2, 1);
> imshow(grayImage, []);
> title('Original Grayscale Image', 'FontSize', fontSize);
> % Enlarge figure to full screen.
> set(gcf, 'Position', get(0,'Screensize'));
> set(gcf,'name','Demo by ImageAnalyst','numbertitle','off')
>
> % Binarize it to get an irregular shape.
> binaryImage = grayImage > 1.4;
>
> with this line to read in your existing binary image:
> binaryImage = imread(fullFileName);
> Of course you know that you need to store the actual filename in the
> variable fullFileName. And if your image is not already logical (or
> at least an integer image with values of only 0 and 1), then you're
> going to have to threshold it like I did.

Subject: Tessellation of irregular shapes

From: bob

Date: 7 Sep, 2011 04:22:12

Message: 14 of 18

Hey,
If you remember this topic. We tried to cover an irregular-shaped area with overlapping circles.
Now, the question is that can we restrict the overlaps just between two circles. I mean I don't want to have areas which they're shared by more than two circles.
Of course, this method increases the number of circles, but it's OK.

thanks,
ImageAnalyst <imageanalyst@mailinator.com> wrote in message <5864cde9-84d3-48cf-baa5-354a3e8b1fb9@t16g2000vbi.googlegroups.com>...
> Replace these lines:
>
> % Generate some sample data that we can get an irregular blob out of.
> grayImage = peaks(256);
> [imageRows imageCols] = size(grayImage);
> % Display the original gray scale image.
> subplot(2, 2, 1);
> imshow(grayImage, []);
> title('Original Grayscale Image', 'FontSize', fontSize);
> % Enlarge figure to full screen.
> set(gcf, 'Position', get(0,'Screensize'));
> set(gcf,'name','Demo by ImageAnalyst','numbertitle','off')
>
> % Binarize it to get an irregular shape.
> binaryImage = grayImage > 1.4;
>
> with this line to read in your existing binary image:
> binaryImage = imread(fullFileName);
> Of course you know that you need to store the actual filename in the
> variable fullFileName. And if your image is not already logical (or
> at least an integer image with values of only 0 and 1), then you're
> going to have to threshold it like I did.

Subject: Tessellation of irregular shapes

From: Bruno Luong

Date: 7 Sep, 2011 06:34:13

Message: 15 of 18

"bob " <behzad.majidi@gmail.com> wrote in message <j46rhk$9mv$1@newscl01ah.mathworks.com>...
> Hey,
> If you remember this topic. We tried to cover an irregular-shaped area with overlapping circles.
> Now, the question is that can we restrict the overlaps just between two circles. I mean I don't want to have areas which they're shared by more than two circles.
> Of course, this method increases the number of circles, but it's OK.

No. Not because you want it then you can find it.

The boundary of the complementary of two overlapped circles has negative curvature everywhere, including at the (2) cross points. So locally it must have a third intersecting circle to fill exterior locally. Conclusion you must have at least 3, not 2.

But if you can (must) tolerate 3, then the pattern is enough to cover any shape:

http://imageshack.us/photo/my-images/853/overlapcircle.png/

Bruno

Subject: Tessellation of irregular shapes

From: bob

Date: 7 Sep, 2011 16:02:28

Message: 16 of 18

Ok. Let me change the problem. Instead of covering all the area, we can use overlapping circles just on the boarder of the shape!
I mean let's use a chain of overlapping circles on the boarder that gives us the shape of the area. size of circles could be changes wherever it is needed.


"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <j47395$17m$1@newscl01ah.mathworks.com>...
> "bob " <behzad.majidi@gmail.com> wrote in message <j46rhk$9mv$1@newscl01ah.mathworks.com>...
> > Hey,
> > If you remember this topic. We tried to cover an irregular-shaped area with overlapping circles.
> > Now, the question is that can we restrict the overlaps just between two circles. I mean I don't want to have areas which they're shared by more than two circles.
> > Of course, this method increases the number of circles, but it's OK.
>
> No. Not because you want it then you can find it.
>
> The boundary of the complementary of two overlapped circles has negative curvature everywhere, including at the (2) cross points. So locally it must have a third intersecting circle to fill exterior locally. Conclusion you must have at least 3, not 2.
>
> But if you can (must) tolerate 3, then the pattern is enough to cover any shape:
>
> http://imageshack.us/photo/my-images/853/overlapcircle.png/
>
> Bruno

Subject: Tessellation of irregular shapes

From: Bruno Luong

Date: 7 Sep, 2011 16:17:28

Message: 17 of 18

"bob " <behzad.majidi@gmail.com> wrote in message <j484ik$eop$1@newscl01ah.mathworks.com>...
> Ok. Let me change the problem. Instead of covering all the area, we can use overlapping circles just on the boarder of the shape!
> I mean let's use a chain of overlapping circles on the boarder that gives us the shape of the area. size of circles could be changes wherever it is needed.

I don't understand what you want to do.

Good luck,

Bruno

Subject: Tessellation of irregular shapes

From: bob

Date: 3 Nov, 2011 19:08:10

Message: 18 of 18

Hey,

No, even what you sent is fine. The thing that I want is "I don't wanna have a pixel which is shared between more than 2 circles."

thanks

"Bruno Luong" <b.luong@fogale.findmycountry> wrote in message <j485eo$hdk$1@newscl01ah.mathworks.com>...
> "bob " <behzad.majidi@gmail.com> wrote in message <j484ik$eop$1@newscl01ah.mathworks.com>...
> > Ok. Let me change the problem. Instead of covering all the area, we can use overlapping circles just on the boarder of the shape!
> > I mean let's use a chain of overlapping circles on the boarder that gives us the shape of the area. size of circles could be changes wherever it is needed.
>
> I don't understand what you want to do.
>
> Good luck,
>
> Bruno

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us