Images don't show properly with imshow after certain calculation
11 views (last 30 days)
Show older comments
Walker on 10 Dec 2019
Commented: Walker on 16 Dec 2019
The question is I need to calculate the matrix of a uint8 image. After the calculation (one order difference of the field) and normalization, I tried to figure out the image with imshow, however, the reults is a white blank or no longer smooth. The figure1.jpg can be any picture as you can find.
I should clarify that the values are uint8 after imread and I used "im2double" to transfer the type to double. The final imshow image is black and the final image will looks like some discrete dots when the matrix times 255.
deltax = 1;
deltay = 1;
AmpDistribution = imread('figure1.jpg')
AmpDistributionDouble = im2double(AmpDistribution);
[MSize, NSize, VSize] = size(AmpDistributionDouble);
DiffoverA = zeros(MSize,NSize,VSize);
for i = 2: MSize-1
for j = 2:NSize-1
for k = 1:VSize
DiffoverA(i,j,k) = (( AmpDistributionDouble(i+1,j,k) -AmpDistributionDouble(i,j,k))./(deltax) + (AmpDistributionDouble(i,j+1,k) -AmpDistributionDouble(i,j,k))./(deltay^2 ));
MinValue = min(DiffoverA,,'all');
MaxValue = max(DiffoverA,,'all');
NormDelta = 255*(DiffoverA -abs(MinValue))/(MaxValue + abs(MinValue));
Bjorn Gustavsson on 10 Dec 2019
When you do things like this the errors are always (in my experience) in different normalizations and type-castings. To work these out I always go to the stage of looking at the individual R/G/B-planes of my images and check where they lie in intensity. Typically something like this:
manualScale = @(I) (I-min(I(:)))/(max(I(:))-min(I(:)));
Then you'll see where your normalised NormDelta are in intensity.
Finally: Your normalization step looks "very peculiar" to me, but I cant say if that is what you want.
More Answers (0)
Find more on Images 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!