How to calculate arithmetic mean of non aligned pixels?

My project is Segmenting retinal vessels. I use DRIVE dataset.
In my project, i have one doubt. Can anyone clarify this.
[0 0 0 1 0 0 0;
0 0 0 1 0 0 0;
0 0 0 1 0 0 0;
0 0 0 1 0 0 0;
0 0 0 1 0 0 0;
0 0 0 1 0 0 0;
0 0 0 1 0 0 0 ]
This is one of the mask (T_d)(there are 12 masks like this). Green channel of a image is taken for the process.
T_di is centered on each pixel p of G and the following parameters are measured:
The arithmetic mean, NAdi(p), of the gray-levels of all pixels of G included by T_di and non aligned along di.
Please clarify it. Thank you.

 Accepted Answer

If you have a two-level mask, M, that selects "aligned" pixels whose mean is to be calculated by the other half of your question, with M being 1 for pixels that are included in the "aligned" and 0 for pixels that are not included as "aligned", then the mean of the "aligned" pixels is
mean_aligned = conv2(YourArray, M./sum(M(:)), 'same' );
Assuming that the non-aligned pixels means everything within reach of the mask but which is not selected as aligned by being 1 in M, then the mean of the "non-aligned" pixels is
nM = double(M~=1);
mean_non_aligned = conv2(YourArray, nM./sum(nM(:)), 'same');
Code that would be more efficient than double(M~=1) would be
nM = 1 - M;
Code that would be more efficient than sum(M(:)) would be nnz(M), and code that would be more efficient than sum(nM) would be nnz(nM)

More Answers (0)

Categories

Find more on Read, Write, and Modify Image in Help Center and File Exchange

Asked:

on 11 Jan 2016

Commented:

on 11 Jan 2016

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!