satellite image pre-processing

조회 수: 8 (최근 30일)
Booker
Booker 2012년 1월 22일
Hello,
I have a satellite image with 365 bands. I intend to get the mean of every 8 bands(that is, (b1+b2+b3+b4+b5+b6+b7+b8)/8, then (b9+b10+b11....b16)/8, and so on? does somebody have a code for this?
Thanks, Booker.

채택된 답변

Bjorn Gustavsson
Bjorn Gustavsson 2012년 1월 23일
Brute looping of this kind of problem shouldn't be too bad.
sz = size(SImg);szMean = sz;
szMean(3) = ceil(szMean(3)/8);
BandMean = zeros(szMean);
for i1 = 1:szMean(3)-1,
BandMean(:,:,i1) = mean(SImg(:,:,8*(i1-1)+[1:8]),3);
end
BandMean(:,:,end) = mean(SImg(:,:,(8*(i1)+1):end),3);
HTH,

추가 답변 (1개)

Walter Roberson
Walter Roberson 2012년 1월 22일
Some image file formats are able to store multiple bands per image, and imread() can read all the bands in at the same time, either as an X by Y by 3 by Bands or X by Y by Bands array (depending on how the data is stored in the image file.)
You can
s = size(ImageMatrix);
By8 = reshape(ImageMatrix, [s(1:end-1), 8, s(end)/8]);
nd = ndims(By8);
mean(By8,nd)
However, you will have a problem because the number of bands you have is not evenly divisible by 8. How do you want to handle the final 5 bands?
  댓글 수: 1
Booker
Booker 2012년 1월 23일
I increased the bands of my image to 368 so should be divisible by 8, but the answer is not correct. I am getting a image with 8 bands (i.e. 55,97,8) at the end instead of 46 bands? as in (55,97,46).

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 CubeSat and Satellites에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by