Help integrating particle intensity

2 visualizzazioni (ultimi 30 giorni)
J
J il 26 Lug 2020
Commentato: Image Analyst il 4 Ago 2020
I'm trying to integrate the intensity from each of the particles in the following image to determine if there are any outliers that need to be discarded:
From what I understand, this is done by summing all the pixels in the PSF by summing the value of the all the pixels contained within a box surrounding each particle defined my the size of the maximum FWHM value.
So right now I have x and y locations for each particle and sigma values for the PSF. Here's the code I have now:
numParticles = numel(sigma);
fwhm = 2.355*sigma;
fwhm = max(fwhm);
fwhm = round(fwhm);
x0 = round(position(:,1)); y0 = round(position(:,2));
for ii=1:numParticles
x = x0(ii)+(-fwhm:fwhm); y = y0(ii)+(-fwhm:fwhm);
x = x(x>0); y = y(y>0);
intensity(ii) = sum(sum(im(x,y),2),1);
end
The problem I'm having is that I'm getting a lot of negative values, which doesn't make sense to me. Can someone point out if I'm doing something wrong?

Risposte (1)

Image Analyst
Image Analyst il 26 Lug 2020
If you have the x and y coordinates of the particles, then just turn them into a binary image and compute the mean intensity and multiply by the areas:
mask = false(rows, columns);
for k = 1 : length(x)
mask(y(k), x(k)) = true;
end
props = regionprops(mask, grayImage, 'MeanIntensity', 'Area')
allAreas = [props.Area]
allIntensities = [props.MeanIntensity]
% Find integrated Gray Value, IGV
igv = allAreas .* allIntensities
  5 Commenti
J
J il 4 Ago 2020
Hmm, well I didn't type anything and just copy-pasted what you gave me. Is that something that I should already have defined?
I tried the other code you gave and have some more questions. I just want to make sure I'm understanding everything.
For the bounding box, I used:
props = regionprops(img, 'BoundingBox');
Is this the right way to do this?
Is it correct to assume that this is identifying particles in the image and putting a box around them, and then the lines for the rows, columns, etc. are for the coordinates of the box? To be clear, "row" is referring to the bottom and top boundries of the box, and column is referring to the left and right boundaries, correct?
One of the problems I'm having is that the bounding box is only around 6 particles, which isn't all of them. So I tried using the coordinates that I already have with your code:
width = 2*fwhm; % fwhm = 5
height = 2*fwhm;
xCenter = position(:,1);
yCenter = position(:,2);
xLeft = xCenter - width/2;
yBottom = yCenter - height/2;
row1 = ceil(xLeft);
column1 = ceil(yBottom);
row2 = row1 + heights;
column2 = column1 + widths;
for k = 1 : numParticles
subImage = img(row1(k):row2(k), column1(k):column2(k));
intensity(k) = sum(subImage(:));
end
But I'm still getting a lot of negative values similar to the original ones, which is wrong. Any suggestions for what I'm doing wrong?
Sorry for all the noob questions. Thank you for all the help.
Image Analyst
Image Analyst il 4 Ago 2020
You should know how many rows and columns your image has. If you don't, get them this way:
[rows, columns, numberOfColorChannels] = size(grayImage);

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by