how to create a loop to calculate the mean of pixels of satellite data of a specified area like india? pixe size of the data is 1440*720
5 views (last 30 days)
Show older comments
% Load or create an image
image = imread('your_image.jpg'); % Replace with your image file name or path
% Determine image size
[rows, columns, ~] = size(image);
% Variables to store sum and count
sumPixels = 0;
countPixels = 0;
% Loop to calculate sum of pixel values and count
for row = 1:rows
for col = 1:columns
% Access pixel value
pixelValue = image(row, col);
% Add to sum
sumPixels = sumPixels + pixelValue;
% Increment count
countPixels = countPixels + 1;
end
end
% Calculate mean
meanPixels = sumPixels / countPixels;
1 Comment
Answers (1)
Shaik
on 15 May 2023
Hey, check this once
% Load or create an image
image = imread('your_image.jpg'); % Replace with your image file name or path
% Define the region of interest (India)
startRow = 200; % Starting row index of the ROI
endRow = 600; % Ending row index of the ROI
startCol = 500; % Starting column index of the ROI
endCol = 900; % Ending column index of the ROI
% Variables to store sum and count
sumPixels = 0;
countPixels = 0;
% Loop to calculate sum of pixel values and count within the ROI
for row = startRow:endRow
for col = startCol:endCol
% Access pixel value
pixelValue = image(row, col);
% Add to sum
sumPixels = sumPixels + pixelValue;
% Increment count
countPixels = countPixels + 1;
end
end
% Calculate mean
meanPixels = sumPixels / countPixels;
0 Comments
See Also
Categories
Find more on Get Started with MATLAB in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!