# 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

4 ビュー (過去 30 日間)
Jincy 2023 年 5 月 15 日
コメント済み: Dyuman Joshi 2023 年 5 月 15 日
% 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);
sumPixels = sumPixels + pixelValue;
% Increment count
countPixels = countPixels + 1;
end
end
% Calculate mean
meanPixels = sumPixels / countPixels;
##### 1 件のコメント-1 件の古いコメントを表示-1 件の古いコメントを非表示
Dyuman Joshi 2023 年 5 月 15 日
What seems to be the problem in your approach?

サインインしてコメントする。

### 回答 (1 件)

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);
sumPixels = sumPixels + pixelValue;
% Increment count
countPixels = countPixels + 1;
end
end
% Calculate mean
meanPixels = sumPixels / countPixels;

サインインしてコメントする。

### カテゴリ

Help Center および File ExchangeImage Processing and Computer Vision についてさらに検索

### Community Treasure Hunt

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

Start Hunting!

Translated by