Saturday, 19 November 2016

matlab - image Normalization, image Range and image Scaling for different stack of images

I am so confused with image Normalization, and image Range, and image Scaling.
I am using an algorithm (I have upload the algorithm in my Previous Question), and after applying the algorithm I am using this formula from wikipedia to normalize the images:




enter image description here



using getrangefromclass(filtImag1{i}) from MATLAB, the range of matrices before applying the algorithm is [0 255] and after applying the algorithm the range is [0 1].



the problem is I need to find a reference to find out if the normalization formula is correct or not? also I have 5 stacks of images each containing 600 images. I have applied the algorithm for each stack, and because the result of algorithm is 10 images for each stack, I will end up with 50 images that I need to analysis and compare them together. I find the max and the min of the 50 images , and then pass each image into the formula to normalize the image.



although the range of the images is [0 1] but the max of the image is :
max = 3.6714e+004



why? shouldn't it be 1?

is this the right way of normalization?
how can I apply scaling ? do I need to do it?



here is the normalization code :



%%%%%%%%%%%%%%Find Min and Max between the results%%%%%%%%%%%%%%%%%%%%%%% 
pre_max = max(filtImag1{1}(:));
for i=1:10
new_max = max(filtImag1{i}(:));
if (pre_max
pre_max=max(filtImag1{i}(:));
end
end
new_max = pre_max;

pre_min = min(filtImag1{1}(:));
for i=1:10
new_min = min(filtImag1{i}(:));
if (pre_min>new_min)
pre_min = min(filtImag1{i}(:));

end
end
new_min = pre_min;

%%%%%%%%%%%%%%normalization %%%%%%%%%%%%%%%%%%%%%%%
for i=1:10
temp_imag = filtImag1{i}(:,:);
x=isnan(temp_imag);
temp_imag(x)=0;
t_max = max(max(temp_imag));

t_min = min(min(temp_imag));
temp_imag = (double(temp_imag-t_min)).*((double(new_max)-double(new_min))/double(t_max-t_min))+(double(new_min));
imag_test2{i}(:,:) = temp_imag;
end


EDIT
I have change the code based on suggested answers but the result is black image



%find the max and min between them

pre_max = max(sTStack{1}(:));
for i=1:40
newMax = max(sTStack{i}(:));
if (pre_max

pre_min = min(sTStack{1}(:));
for i=1:40
newMin = min(sTStack{i}(:));
if (pre_min>newMin)
pre_min = min(sTStack{i}(:));

end
end
t_min = pre_min;



%%%%%%%%%%%%%%%%%%%%%%% Normalize the Image:%%%%%%%%%%%%%%%%%%%%%%%%%%%%



for i=1:40
NTstack{i} = (sTStack{i} - t_min)/(t_max-t_min);
end




for i=10:10:40
figure,imshow(NTstack{i});
colorbar
colormap jet
end

No comments:

Post a Comment

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...