colored tablet tracking
Hello everyone,
I am trying to track 3 colored particles (blue, black and pink, an image set is attached below) in a rotating drum that is filled with only white tablets apart from the 3 colored ones mentioned above. I am able to do that with the pink tablet because I already have a file that detects the pink tablet, but this file was sent to me and I do not know how to create one for black and blue tablets accordingly. So basically, I am looking for files that can detect black and blue pills in a drum filled with white pills. The purpose of the analysis is to get the x- and y-displacement of the colored tablets and then to calculate their velocity. I have also attached an excel shhet were the general form of my results at the moment can be seen.
What I am doing at the moment is loading in 2000 consecutive frames of the drum video. Then I am using a macro that selects the pink tablet with the file and uses the automatic tracking tool inside image pro and I get an excel sheet where x- and y-position as well as distance are measured. But I somehow can not figure out a way to track the black and blue tablets.
My priority is that I can tell in the end which tablet is responsible for which track so I am looking for files that select only the black and only the blue tablet. The next highest priority is to be able to track all 3 tablets in one run for an image sequence.
Could you please provide me a solution for this or send me a file that detects the blue and the black tablet.
Thanks in advance and best regards
Justus
Comments
Segmenting Blue pill will be similar to segmenting of Pink pill. You can load PinkPillTracking.tro, which you received earlier, and change the Hue range in the threshold dialog to Blue range (157-190):
I've attached the BluePillTracking.tro as example.
I didn't see black pills on your images, but tracking a black pill could be a challenge as it may have the same color as shadows of white pills. Blue and Pink pills have saturation, which could be used for detecting these pills, black color doesn't have saturation, so if you can control the experiment, I would recommend using pills with saturated colors,which could be easier segmented (not gray shades).
Also, I would recommend saving images to TIF format instead of JPG, as JPG compression corrupts colors and make them harder to segment.
Yuri
Dear Mr. Yuri,
Thank you very much for answering my question. So I have tried what you propose in your text and most of it worked and was of great help. The .tro file works for blue and black pills equally and when I crop my images in such a way that no part of the drum is visible such that the positions on the wall are not treated as pills wrongfully. But that also means that the .tro file is not able to distinguish between blue and black pills. This could be due to the similar color of the tablets. Anyways this is not so much of an issue to me right now, because I can work with distinguishing between 2 colors of pills (red and blue). The file was very helpful in this way, thanks again. Can you suggest what color are best suitable for saturation? Please suggest three colors apart from red.
But there is another problem which I would like to address here. It would be of great use to me if you have an answer to this as well. No matter how I set the Hue range, or which channel I use in the manual segmentation I can´t seem to detect all pills in each track. They usually break in the upper third of the image although the pill is still visible. I will attach screenshots of two tracks where this happened (one is blue and the other one is a black pill) and the original frames (.jpg or .tif files made no difference here).
Please kindly let us know if you can help us here.
Best regards and thanks in advance
Justus
Saturation is defined by the max difference in RGB components of the color (e.g. Red=255, Blue=0, Green=128 - saturation is max 255 (Red-Blue)), so to have high saturation the color should be bright as well (dark blue has low saturation and will be harder to detect), examples of colors with max saturation are: Red, Green, Blue, Yellow, Cyan, Magenta. The segmentation range is defined by 3 ranges: Hue, Saturation and Intensity, so as long as these ranges segment only the color pill, the tracking should work properly.
Regarding problems with segmentation in the upper third of the image. It looks like the illumination in that area is darker, which affects color of the pill, it gets darker, less saturated. So, if you have control over the experiment, you may try changing the location of the light to make the illumination more uniform. Also, if possible, use diffused light that produces less shadows.
Yuri
thanks a lot for your answer. I myself am not doing the experiments but I will try to adjust the illumination in the future thank you very much for the advice. Regarding the saturation I think it is clearer to me after your explanation and thank you for the color suggestions as well. This again was really helpful:) I will play around with the segmentation a bit more and get more familiar with that, so I can solve those problems myself in the future, looking forward to that.
Best regards and thank you for your help
Justus
thank you for your reply. I heard of experiments with polarized lights in my studies, so I am kind of familiar with that and I think it might make sense to use it in my experiment. Anyway thank you very much for your advice and the link, I will think about that as well and post here how this worked out:)
Best regards and thank you for your reply
Justus
after a little break I again started working on the tablet tracking. So I did a few tests and there still are some issues unfortunately which I can´t seem to be able to solve. Maybe some of you could help with this.
1. One thing happens regularly when tracking the blue tablets. IP 10 wrongly detects blue particles all over the frame even if the outter parts of the drum are cropped. This is addressed in the zip file 1(frame 195-203 and frame 274-290 are the frame sequences which I analysed and tr 193-203 and tr 274-290 are the tracking images I received from IP 10). I want to avoid this behaviour because my aim is to only track the blue particle. For tracking I use the BluePilltracking.tro file Mr. Yuri kindly provided in a earlier post in this discussion. Can anyone explain why this happens or what I am doing wrong? I am not sure if my understanding of poor saturation is correct but I thought poor saturation leads to not detecting the blue tablet and not to detecting blue tablets wrongly. Am I correct with this?
2. Another problem I came across is that I can not track the red particle in the attached frames. I had this problem with the blue tablet before and this was traced back to the issue of poor lighting in the upper third of the image which resulted in low saturation. due to this IP 10 can not identify my tablet. This was for the blue tablet but there were other issues to the blue tablet tracking as well. So I am wondering whether this is the same problem for the red tablet? Images which have this problem can be found in the zip file 2. I also attached the tracking file I used for the red tablet.
I would be very thankful for any answers.
Best regards
Justus
frame241.jpg
frame246.jpg
It looks like the illumination conditions in your experiments are different from run to run. In some cases you get white lighting, but in some cases, as in your new samples, bluish tint, when tint changes, the Hue of the pill is also affected.. You may try to standardize the illumination and/or adjust white balance of your camera, so white pills don't have any color shades.
If it's impossible, you have to readjust segmentation ranges for every run. You can open the threshold dialog switch to HSI color space, reset the ranges and use the Color picker to pick the colors of your pill, until the pill is segmented properly:
Yuri