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 visualizaciones (últimos 30 días)
% 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;

Respuestas (1)

Shaik
Shaik el 15 de Mayo de 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;

Categorías

Más información sobre Get Started with MATLAB en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by