creating dye distribution profile with image processing

5 views (last 30 days)
Hi All. I have two photos taken from a sandbox.the first one is reference and second one is the same sandbox after injection of dye which is blue. I did the following: ref=imread('ref.jpg'); p1=imread('photo.jpg'); dif=ref(:,:,:)-p1(:,:,:); imshow(dif)
since everything is the same in both pictures except dye, I expect to see the dye distribution by subtracting second photo from reference photo which doesnt have any dye but at the end I got a very black picture. does anybody know how to do this? I am a beginner so any help would be appreciated. Thanks.

Accepted Answer

John D'Errico
John D'Errico on 20 Feb 2017
Edited: John D'Errico on 20 Feb 2017
If both pics are mostly identical, then what do you get when you subtract them? ZERO.
What color is [0 0 0]? Black. So you saw black. This is no surprise.
Worse, if the images are scaled [0-255], then they are stored as uint8 arrays. If the second number in a difference is larger than the first, the difference truncates at zero. Again, black.
So it depends on what you want to see, how you want to view it. I'd probably convert the images to double arrays, using double. Then when you subtract the two arrays, negative numbers will still make sense.
Next, I'd then shift and scale the difference so that a difference of zero would get mapped to a mid-level gray, and then I'd convert back into uint8 to return it into an image form.
  1 Comment
melody Sharifi
melody Sharifi on 21 Feb 2017
Hi John, I converted both photos to double and I subtracted them. now I can see the dye distribution better but it is still dark and I dont know how to scale it. would you please let me know how to scale it. thanks so much.

Sign in to comment.

More Answers (0)

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!