Home Image-Pro Automation (Macros, Apps, Reports)

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

  • edited December 2021
    Hi Justus,

    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


  • Hi 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
  • 2021-12-17-145215

    Justus --

    You may also want to experiment with POLARIZED LIGHT to reduce / eliminate GLARE.

    There is a very good explanation of this at


    Where the IMAGES below were found.

    I hope this helps.

    -- Matt






  • Dear Mr. 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
  • Dear Mr. Matt,

    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
Sign In or Register to comment.