Pixel location to intensity value

1 visualizzazione (ultimi 30 giorni)
Hugo
Hugo il 11 Nov 2013
Risposto: Image Analyst il 11 Nov 2013
I'm trying to create a algorithm that calculates the mean intensity of a given pixel and it's neighbors, i use the script beneath to select a slice and pixel in my volume and build a matrix with the pixel and neighbor locations. Can anybody help me to translate this location to an intensity value?
if true
% Slicenumber = round(size(MRI1 ,3)/2);
figure, imshow (MRI1(:,:,Slicenumber),[]);
uiwait(msgbox('Select a point'))
[x,y]=getpts;
Position(1) = round(double(x(1)));
Position(2) = round(double(y(1)));
Position(3) = Slicenumber;
a = [ 1 0 0; -1 0 0; 1 1 0; 0 1 0; -1 1 0; 1 -1 0; 0 -1 0; -1 -1 0];
neighbors = a+repmat(Position,[8 1]);
end

Risposta accettata

Image Analyst
Image Analyst il 11 Nov 2013
Use convolution:
grayImage = double(MRI1(:,:,Slicenumber));
kernel = ones(3)/9;
neighborhoodMeans = conv2(grayImage, kernel, 'same');
You could also use imfilter().

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by