efficient use of extracting mean over segments

3 vues (au cours des 30 derniers jours)
Sukuchha
Sukuchha le 20 Fév 2013
Hello, I have image (Iseg) where i have number of segments. Each segments is represented by unique number in Iseg. The segments are around (50000). I have another image(Idata) which is same size that of Iseg. For every segment in Iseq i want to extract mean value of segments from Idata.
Rightnow i am using like this
NumRegion = max(max(Iseg));
mean_magnitude = zeros(size(Iseg));
for i=1:NumRegion
[iIndList] = find(Iseg == i);
mean_magnitude(iIndList) = mean(Idata(iIndList));
end
It works fine, but the problem is that it takes a long time. about 10 mins in my machine. Is there a effecient way to do it.
  3 commentaires
Image Analyst
Image Analyst le 22 Fév 2013
Modifié(e) : Image Analyst le 23 Fév 2013
I'm not sure either. Is a "segment" a blob in a binary image? And he wants the mean gray level of a gray level image for each blob region? Sounds like Iseg is a "labeled" image like you'd get from bwlabel (connected components labeling) where each blob has a unique ID number assigned at every pixel in the blob.
Sukuchha
Sukuchha le 25 Fév 2013
Image Analyst, you are right. Iseg is a grayscale image, where each blob has a unique ID number assigned at every pixel in the blob.

Connectez-vous pour commenter.

Réponse acceptée

Image Analyst
Image Analyst le 22 Fév 2013
Modifié(e) : Image Analyst le 22 Fév 2013
Do you, by chance, mean this:
measurements = regionprops(Iseg, Idata, 'MeanIntensity);
allMeanIntensities= = [measurements.MeanIntensity];
  5 commentaires
Sukuchha
Sukuchha le 25 Fév 2013
i had a look at intlut before but couldnot figure out how to use it. Could you please show one example(or pseudo code)?
Image Analyst
Image Analyst le 25 Fév 2013
Something like (untested)
newImage = intlut(labeledImage, allMeanIntensities);

Connectez-vous pour commenter.

Plus de réponses (1)

Jan
Jan le 22 Fév 2013
At first you can cleanup the loop a little bit using logical indexing:
NumRegion = max(max(Iseg));
mean_magnitude = zeros(size(Iseg));
for i = 1:NumRegion
iIndList = (Iseg == i);
mean_magnitude(iIndList) = mean(Idata(iIndList));
end
I assume accumarray is faster. I'd try to run a loop over Iseq instead also, but I cannot test it due to the absence of test data. It might be helpful if you post some, e.g. produced by some rand calls.
  1 commentaire
Sukuchha
Sukuchha le 25 Fév 2013
Modifié(e) : Sukuchha le 25 Fév 2013
The looping is much slower. The code given by image analyst calculated mean intensities over each blob in much faster way but problem now to to make a raster image out of it. measurements = regionprops(Iseg, Idata, 'MeanIntensity); allMeanIntensities= = [measurements.MeanIntensity];

Connectez-vous pour commenter.

Catégories

En savoir plus sur Get Started with Image Processing Toolbox dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by