0

I have a statement trying to implement but confused on how to do so. This is my issue:

  • I have an image where I have set some pixels of interest (region of interest) to the value 1. So, we can say that we now have a set with the following values 1s where each 1 here represents a particular location in the image.

C = [1 1 1 1 1 1 1 1 1 1];

For example, say img for simplicity here is the matrix x as follows:

x = [2 3 5; 5 4 5; 6 4 3; 6 5 4; 6 54 3; 6 5 3];

x will have a degree of membership y based on which we set some values to 1. To clarify, for each pixel for which y = 1 we set that pixel to 1. So, let's say y is:

y = [0 1 0; 0 1 1; 1 1 0; 0 0 1; 0 0 1; 1 1 1];

So, C contains 10 1s. For instance the first 1 represents the location x(1,2) and so forth...

  • Now, I want to check the 4-neighbourhoods of the pixels in C but that at the same time not in C. That is, on the surroundings.

  • Now, for those pixels that belong to the surroundings and are four neighbors of C I want to select that pixel p that minimizes the distance between x and C.

Is it clear now? Do you know how I can go around it?

Thanks.

Simplicity
  • 47,404
  • 98
  • 256
  • 385
  • I don't quite understand what you are trying to do here. However, you say you are confused by the phrase "minimise the distance"; if it helps, that *might* mean the distance between the pixel values, i.e. how different the image looks. Perhaps you could give more information and say whether you think my guess would make sense for your problem. – devrobf Feb 22 '13 at 10:23
  • What is the `size` of `img` and `p`? – Dennis Jaheruddin Feb 22 '13 at 10:23
  • Thanks for your replies. I will add more information to my question – Simplicity Feb 22 '13 at 10:27
  • Maybe you can solve this problem manually for a small matrix... this will help us to write a generalized psuedo code – Autonomous Feb 22 '13 at 10:51
  • What would be the criterion according to which a distance would be minimal? – Jonas Feb 22 '13 at 11:59
  • @Jonas. This will depend I think on the distance function and comparing the results of those distance functions – Simplicity Feb 22 '13 at 13:51
  • @prog: So... what is the question then? Given `y`, how do you find all the candidate pixels? – Jonas Feb 22 '13 at 14:02

1 Answers1

0

If you want to find the pixels that are 4-neighbors of the pixels in y, but not y themselves, you can use imdilate like this:

msk = zeros(3);
msk(2,:) = 1;
msk(:,2) = 1;

tmp = imdilate(y,msk);

result = tmp & ~y;

Now you can get the pixel values as C(result), and apply your distance function.

Jonas
  • 74,690
  • 10
  • 137
  • 177