Median filter,block averaging

조회 수: 1 (최근 30일)
Nadia jabeen
Nadia jabeen 2020년 9월 17일
댓글: Image Analyst 2020년 9월 23일
I have applied Median filter and block averaging on SAR image of tif format. The output image has black lines which are not part of input image. Kindly improve my code to remove these lines.
start_path='E:\practise';
topLevelFolder = start_path;
if topLevelFolder == 0
return;
end
filePattern_1 = sprintf('%s/**/HH/', topLevelFolder);
filePattern = sprintf('%s/*.tif', filePattern_1);
allFileInfo = dir(filePattern);
isFolder = [allFileInfo.isdir];
allFileInfo(isFolder) = [];
listOfFolderNames = unique({allFileInfo.folder});
numberOfFolders = length(listOfFolderNames);
fprintf('The total number of folders to look in is %d.\n', numberOfFolders);
totalNumberOfFiles = length(allFileInfo);
if totalNumberOfFiles >= 1
for k = 1 : totalNumberOfFiles
% Go through all those files.
thisFolder = allFileInfo(k).folder;
thisBaseFileName = allFileInfo(k).name;
fullFileName = fullfile(thisFolder, thisBaseFileName);
% fprintf(' Processing file %d of %d : "%s".\n', k, totalNumberOfFiles, fullFileName);
% To get images and their georeferencing
[A,R]=geotiffread(fullFileName);
Y= db2pow(A );
% % To apply median filter
B = medfilt2(Y,[100 100]);
% % To apply block averaging
meanFilterFunction = @(theBlockStructure) mean2(theBlockStructure.data(:));
blockSize = [10 10];
blockyImage = blockproc(B, blockSize, meanFilterFunction);
blockyImage(isnan(blockyImage))=0;
X= pow2db(blockyImage);
% % % To save images and their names as a single mat file
Alpha(k).name=thisBaseFileName;
Alpha(k).img=X;
% Get lat and lon of blocked images
R_blocked = R;
R_blocked.RasterSize = size(X);
%To save georeferencing of all images as a single mat file
R2(k).name=thisBaseFileName;
R2(k).Georeferencing=R_blocked;
save('Preprocessed.mat','Alpha', 'R2');
clear X
end
else
end
  댓글 수: 1
Image Analyst
Image Analyst 2020년 9월 23일
Because of geotiffread(), it looks like it needs the mapping toolbox or something.

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

답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by