mat2gray implementation affecting output
Show older comments
Hi everyone,
I am using a program called Multem to generate simulated TEM nanoparticle images. I have adapted the program to produce images that reflect detector influence on the images. I include the modulation transfer function (MTF) as well as the noise transfer function (NTF) of the detector. These two properties describe how the signal and noise are influenced by the detector respectively. The noise I am primarily focusing on is shot noise, which I include using poissrnd(A), where A is the electron dose per image. The values of A vary from 2.6e6 to 8.07e7.
The code structure is as follows:
img1 = noiseless image (output from Multem)
%including the MTF
img2 = fft(img1).*(MTF) ----(1)
img3= ifft(img2) ----(2)
%including noise
t= total dose per image
img4 = poissrand(t); ----(3)
img5 = fft(img4).*(NPS) ----(4)
img6 = iff(img5); ----(5)
%multiplying MTF attenuated signal by noise attenuated by the NPS
img7= img3.*img6 ----(6)
%saving image as tiff
imwrite(mat2gray(img7),...'.tif') ----(7)
I run into the following issues when I use mat2gray;
When I do use it on steps (2,3,5, 6 and 7);
- the noise standard deviation is the same for all A values and the noise appears exaggerated even for high A values
When I exclude it on step 5;
- the noise standard deviation is the same for all A values and the noise appears low even for low A values
When I use it only in writing the final images the outcome is almost no noise at all;
Also, when I don't use it at all steps images I retrieve white images with no information.
I have attempted several other combinations but the outcomes have remained the same either there is too much or too little or no noise at all. When is it appropriate to use mat2gray and when is it not? Typically the data are meant to reflect dose dependence but in this case I am not getting that.
Any advice and pointers are welcome,
Thank you
1 Comment
DGM
on 26 Apr 2021
mat2gray(A) is going to normalize the data to the range of its extrema. Any offset information is lost. The minimum (e.g. 2E6) gets mapped to 0. The maxima gets mapped to 1. If this is going to mess up subsequent calculations, you may try specifying the range which mat2gray() uses when normalizing. Given the extreme offset though, you might run into precision issues with the numeric class used when writing to tiff. I'm not sure of what to recommend, and I'm not even sure this information is helpful to you.
Accepted Answer
More Answers (0)
Categories
Find more on Image Arithmetic in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!