From: Zuofeng on
Hi to all,

Here is a question which I cannot solve. Appreciate so much for any suggestions!

I have a squared region which is irregularly divided into many rectangular patches.
Each patch is associated with a value, and two patches possibly share a common value.
I hope to fill in each patch a pattern according to its value. For instance, if a patch has value 1, then I fill in that patch with pattern A; if it has value 2, then fill in it with pattern B,...

The pattern is something like a rectangular region with certain colored lines in it. For instance, pattern A may be a white rectangular region filled in by two thick black lines;
pattern B may be a white rectagular region filled in by 10 thick black lines,...

Is this available in matlab? I have serached "polygnon" in matlab user guide and found a
"fill function" may work, however, there is still a long way to finally complete it.

Many thanks again!
Zuofeng
From: ImageAnalyst on
Zuofeng
Here's what I would do. Make each pattern the size of the entire
image. Then for each patch's gray level, threshold the image at that
gray level and use logical indexing to assign the output image the
values from the pattern image that you want to use. Make sense?
-ImageAnalyst

From: ImageAnalyst on
Post your input image, and your pattern images to http://drop.io.
From: Zuofeng on
Hi ImageAnalyst,

Thanks a lot for response!

This idea maybe works, but I still have two questions.

1. Suppose I have made pettern A an image the same size as my original image,
then how do I threshold it at the gray level of A? My concern is that it is possible to threshold only a part of pattern A which is not my original pattern A.

2. How do I assign the output image a logical index? There may be many values from a pattern, how do I assign them all to an output image?

Please forgive me if I have misunderstood your idea! Many thanks!

Zuofeng


ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <be2cf1bd-43e1-4d28-b452-5026aaac1385(a)b10g2000vbh.googlegroups.com>...
> Zuofeng
> Here's what I would do. Make each pattern the size of the entire
> image. Then for each patch's gray level, threshold the image at that
> gray level and use logical indexing to assign the output image the
> values from the pattern image that you want to use. Make sense?
> -ImageAnalyst
From: ImageAnalyst on
1. You have to decide where the "patches" or regions are.
Thresholding is one way, such as this way to get a binary image of
where all the pixels with value 4 are:
% Generate some sample data in the range 0-9.
a= uint8(10 * rand(8,8))
% Get a logical array of pixels with a value of 4.
pixelsOfValue4 = (a == 4);
Or you could pick a range like
pixelsOfValue4through6 = (a >= 4) & (a <= 6) ;


2. This demo should explain it:
% Generate some sample data in the range 0-9.
a= uint8(10 * rand(8,8))
% Get a logical array of pixels with a value of 4.
pixelsOfValue4 = (a == 4);
% Reassign to 99 instead of 4.
a(pixelsOfValue4) = 99