Using Values from an image array in an equation to give a new image
1 view (last 30 days)
Show older comments
Robert Roy
on 21 Aug 2015
Commented: Image Analyst
on 21 Aug 2015
Hi there, I have two images arrays that I want to ratio in an equation to give a new image T however I am having problems doing this.
AvgImg1 = uint16(zeros(1024,1280)); AvgImg1 Values
AvgImg2=uint16(zeros(1024,1280)); AvgImg2 Values
K1=imagesc((AvgImg1));
K2=imagesc((AvgImg2));
T=uint16(zeros(1024,1280)
T=constant*ln(K1/K2);
plot T
0 Comments
Accepted Answer
Image Analyst
on 21 Aug 2015
So what do you think 0/0 should give? Also, don't make them integer if you're going to divide them. And use imshow(T, []) instead of plot() to display the resulting image. And you don't need to preallocate T in this case.
2 Comments
Image Analyst
on 21 Aug 2015
Don't use K1 and K2 at all - they're just handles to the images, not the images themselves which are called AvgImg1 and AvgImg2. Cast them to double or else you will get an integer divide and the quotient will be either 0 or 1. Then use ./ instead of / to do an element by element divide.
AvgImg1 = uint16(zeros(1024,1280)); %AvgImg1 Values
AvgImg2=uint16(zeros(1024,1280)); % AvgImg2 Values
subplot(2,2,1);
imshow(AvgImg1);
subplot(2,2,2);
imshow(AvgImg2);
T=constant*ln(double(AvgImg1) ./ double(AvgImg2));
subplot(2,2,3);
imshow(T, []);
More Answers (0)
See Also
Categories
Find more on Image Processing Toolbox 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!