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 (최근 30일)
% 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개)

Shaik
Shaik 2023년 5월 15일
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;

카테고리

Help CenterFile Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by