creating dye distribution profile with image processing

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.

 채택된 답변

John D'Errico
John D'Errico 2017년 2월 20일
편집: John D'Errico 2017년 2월 20일

1 개 추천

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

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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

질문:

2017년 2월 20일

댓글:

2017년 2월 21일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by