How to convert the mean value of an integer matrix to a double
Ältere Kommentare anzeigen
Hello,
I am importing an image as a 2D matrix using
importdata('myImage').
I am then trying to search 4x4 pixel regions of that image and calculate the mean of each image to determine which region has the highest mean value. However, MATLAB will only return the mean values as integer numbers. How do I make it return values as type double?
My code for the mean is as follows.
for ii = 1:((frameHeight/2)-3)
for jj = 1:(frameWidth-3)
regionA(ii,jj) = mean(mean(frame1(ii:ii+3, jj:jj+3), 'double'));
end
end
for ii = (frameHeight/2):(frameHeight-3)
for jj = 1:(frameWidth-3)
regionB(ii,jj) = mean(mean(frame1(ii:ii+3, jj:jj+3), 'double'));
end
end
(I'm splitting the image into a top and bottom half to separate objects in the image and trying to find the max region in each half.)
Also, sorry for the poor formatting. It's my first time posting here and I'm not sure why part of the code isn't showing up correctly. But basically, what can I do to make the mean output as type double? Any help would be greatly appreciated.
-Jon
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Image Arithmetic finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!