-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpreprocessFiles.m
35 lines (31 loc) · 1.04 KB
/
preprocessFiles.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
function imgPreProc = preprocessFiles(im,parameters)
% imgPreProc: This function remove striping noise from image and denoise the image with a median filter
%
% Syntax: imgPreProc = preprocessFiles(im, parameters)
%
% Inputs:
% im - RGB image
% parameters - structure- the following fields in the structure :
% (1) parameters.med_pre: is the window size of the median filter
% Outputs:
% imgPreProc - preprocessed image
%
% University of Florida, Electrical and Computer Engineering
% Email Address: [email protected]
% Latest Revision: May 5, 2019
% This product is Copyright (c) 2019 University of Florida
% All rights reserved.
med_pre = parameters.med_pre;
[rows,cols,dims] = size(im);
im = im2single(im);
meanCol = squeeze(mean(im,1));
meanI = mean(meanCol);
%% remove stripping noise
for i = 1:dims
imgPreProc(:,:,i) = im(:,:,i) - repmat(meanCol(:,i)',[size(im,1),1]) + meanI(i);
end
%%denoise with median filter
for i = 1:dims
imgPreProc(:,:,i) = medfilt2(imgPreProc(:,:,i), [med_pre med_pre]);
end
end