11-14-2018 07:43 AM - edited 11-14-2018 07:50 AM
Hello,
I am working on differential phase contrast imaging project,
Where, I have to generate the differential phase contrast image from two images taken with opposite illumination angle.
Steps to generate the DPC image
1) Add to images .................................................................get image 1
2) Subtract Two images from each other.............................get image 2
3) Divide image 2 / image 1................................................(DPC image)
Equation is = DPC(image) = I(L) - I(R) / I(L) + I(R)
I(L) = image taken by illuminating the left half circle.
I(R) = image taken by illuminating the right half circle
Illumination pattern
So, made VI to do the same task, but I got to know that I can not work with U8 to desire result, so I need to convert the U8 image into U16 or after loading the image ,the pixel values re-format into datatypes with higher bits
So, if some knows the solution then just let me know.
I will be very helpful to me.
I have attached the VI and both images.
Thank you.
Solved! Go to Solution.
11-14-2018 08:20 AM
Hi,
I think what you need is the "IMAQ Cast Image" function from the Vision module.
Regards!
11-14-2018 11:03 PM
Think a bit about what you are doing. Your formula may well be correct, but here are some things that bother me:
I think converting to 16-bit may be "solving the wrong problem" ...
Bob Schor
11-15-2018 03:51 AM
I extend unsigned number.
As I need to get the phase information from the intensity of the images I need to re-form image into U16 to get out more information and U8 is not suitable to do image processing while it provides detail between 0 to 255.
By subtracting two images taken from the opposite angle of illumination. I have phase gradient information and anyway I have to remove the background information.
I asked to my professor and he asked me to do ''
After loading the images, the pixel values should be re-formatted into datatypes with higher bits , e.g., double. UNIT8 is 8bit, not suitable for computation.''
what I am doing is, if I do summation of two images I will have images like sown below (I(T) + I (B)) and when I use that above equation I will have dpc image like shown below.
11-15-2018 09:59 AM
OK, that's pretty helpful. So let me reformulate the problem slightly.
There are two problems with U8 -- one is the "unsigned" aspect which raises a problem with a Subtract operation (since one less than 0, a "little bit darker than black", gives 255, "white", which doesn't make sense). The other is the fact that Integers don't do well with division. What numeric format supports subtraction and division? Floats.
So let's remap U8 to a Float, and see what makes sense. Let's start by saying "Black is 0, White is 1". Let's look at (A - B) / (A + B). Here's a little exercise you can do (I just did it, took me less than 5 minutes) -- generate two arrays of 11 numbers from 0, 0.1, ..., 1.0, and call them A and B. Create the 2D array of A-B / A+B and look at the results. You'll find that except when A and B are both 0, all of the numbers range from +1 to -1. I'm not sure it would make sense, but taking Absolute Values gets us back to a 0 .. 1 range (except when A and B are both zero).
So armed with this, I went back to your code and found one "silly mistake" (look at the Division operation -- you are dividing A+B by A-B, oops ...). Look at the Images you are creating using IMAQ Create -- by default, they are all U8. So make them all Grayscale (SGL). Fix the earlier image. Also run the Error Line between the IMAQ functions, so if there is an Error (like Division by 0) somewhere, you'll know about it. It will (perhaps) also help you to keep your Block Diagram more tidy.
Once you've cleaned up the code (clean it up first, please), try running it. You might be pleasantly surprised. [I'll note that your Left and Right images seem a little too similar to each other ... maybe you can get a better Image pair].
Bob Schor
11-21-2018 04:13 AM
Finally I got the Differential Phase Contrast Image by following the steps you suggested.
Thank you very much for helping me solve my problem and clearing out the my doubts.
I got the solution but still this I do have idea what you trying to say in below quotes.
'' generate two arrays of 11 numbers from 0, 0.1, ..., 1.0, and call them A and B. Create the 2D array of A-B / A+B and look at the results. You'll find that except when A and B are both 0, all of the numbers range from +1 to -1. I'm not sure it would make sense, but taking Absolute Values gets us back to a 0 .. 1 range (except when A and B are both zero)''
As I am working to get the phase details from the two images taken at opposite angle of illumination , so both images will look a like same, but the intensity information will be different and I use intensity details to recover the phase information.
Thank you very much again.