none
How to segment shape of bottle RRS feed

  • Question

  • Hi,

    I'm having a problem to segment the bottom shape of bottle. Below is original image and  segmented image. Can anyone help me to solve this problem? 

    Regards,

    Bella

    Friday, March 23, 2018 8:23 AM

All replies

  • You'd have to show us the code you are using to get the image thus far.  It would seem that you need more sensitivity to low contrast colors.

    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

    Friday, March 23, 2018 12:49 PM
    Moderator
  • Hi,

    you need to specify a bit more what you exactly want. Do you need the whole bottle, or just the filling?

    Here's some quick results:

    a) sobel magnitude:

    b) HSL based alpha removement (plus a bit smoothening the edges):

    c) greyscale a copy and subtract from original (exactly: apply the difference operator):

    Maybe you could use the best of all three to get the desired result. You also could do some morphological operations, or use a k-means segmentation.

    If you have a mathematical background you also could do a segmentation based on a partial differential equation like "active contours" but this is *much* more expensive in cpu usage and time then one of the above.

    Regards,

      Thorsten

    Friday, March 23, 2018 9:07 PM
  • Hi,

    you need to specify a bit more what you exactly want. Do you need the whole bottle, or just the filling?

    Here's some quick results:

    a) sobel magnitude:

    b) HSL based alpha removement (plus a bit smoothening the edges):

    c) greyscale a copy and subtract from original (exactly: apply the difference operator):

    Maybe you could use the best of all three to get the desired result. You also could do some morphological operations, or use a k-means segmentation.

    If you have a mathematical background you also could do a segmentation based on a partial differential equation like "active contours" but this is *much* more expensive in cpu usage and time then one of the above.

    Regards,

      Thorsten

    Hi,

    I want to get the image like below. Maybe I need to adjust the lighting at the bottom side of the image? or it is possible to get the image like below using the same image? 

    Saturday, March 24, 2018 4:24 AM

  • Hi,

    I want to get the image like below. Maybe I need to adjust the lighting at the bottom side of the image? or it is possible to get the image like below using the same image? 

    ...

    Hi,

    the problem I see with increasing luminance on the bottom part of the image is that this type of processing is very sensitive to small changes in illumination. You would have to distinguish by a fixed value, what amount of luminance is part of that lower part and what should not be processed. The edge between the lighter and darker part on the other hand, might not be that sharp in the picture. so you probably get a gradient over some small amount of pixels in y-direction which might make it impossible to remove that edge by adding luminance to the bottom part of the image in a stable way. If it works for one pic, its not said that it does for other pictures.

    My suggestion is to use a 2-picture strategy. Apply an edge detection to the orig image and crop the upper part (remove the bottom part including the unwanted edge between the table and the wall) for the next step. Then, on a copy of the orig image, get the shape of the fluid inside the bottle, maybe by grayscaling and subtracting as I said above. Then remove the background on both pictures and merge them. A typical result would look like:

    Regards,

      Thorsten

    Saturday, March 24, 2018 5:54 PM
  • Nice to see you Thorsten. That code you did awhile back I haven't had a chance to try, where you put an eyeball into a hand, seems way cool. But I don't believe I could understand how it works to the level necessary for the complexity of it. I thought a hand puppet with two eyeballs on it would look cool. And maybe even a mouth!

    And segmenting a bottle I thought meant cutting it into different pieces from top to bottom or something...:)

    Anyhows have a good day!


    La vida loca

    Saturday, March 24, 2018 8:53 PM
  • Nice to see you Thorsten. That code you did awhile back I haven't had a chance to try, where you put an eyeball into a hand, seems way cool. But I don't believe I could understand how it works to the level necessary for the complexity of it. I thought a hand puppet with two eyeballs on it would look cool. And maybe even a mouth!

    [...]

    Hi John,

    <ot>nice to see you too, the idea behind it is to blend parts of images seamlessly. This is realized by processing the gradient(s) of the image(s), so that the gradient of our function to look for has minimal difference to the gradient of the (upper-)image-part that we want to put into the "lower" image - with the boundary (color channel vals at the boundary) of the lower image. A minimization problem, that, when applying the Euler-Lagrange-Equation yields a Poisson Equation. See these links:

    http://www.cs.princeton.edu/courses/archive/fall10/cos526/papers/perez03.pdf

    http://www.ctralie.com/Teaching/PoissonImageEditing/

    As long as the backgrounds of both images are "somewhat similar" you can compose really crazy things with it...

    So, indeed its a bit of maths and a bit of numerics to solve the equations, but its been so much fun, that I stayed with it and implemented alternative ways to solve (most recently Conjugate Gradients and BiCGSTAB methods...).

    I found out that you not only can use it to blend objects into other objects, but its also extremely useful when blending very fine structures like hairs from one image to another. You maybe have had the problem once or twice when cropping a part of an image to compose in another scene, that there's simply no way to crop those fine structures whithout also copying unwanted color data. Thats simply because such a thin object like a hair is *smaller* then one pixel in diameter, so the containing pixel will have some amount of the hair-color plus some amount of the background color as smallest element.

    You probably can also use this technique to map colors from one image to another (I think I read something about poisson blending when stitching images to a panorama).</ot>

    [For the bottle I suggested that two picture process because I simply have no idea how to reliably do this with just one pic, when considering some changes in lights when taking the photo...]

    Regards,

      Thorsten


    Saturday, March 24, 2018 10:05 PM

  • Hi,

    I want to get the image like below. Maybe I need to adjust the lighting at the bottom side of the image? or it is possible to get the image like below using the same image? 

    ...

    Hi,

    the problem I see with increasing luminance on the bottom part of the image is that this type of processing is very sensitive to small changes in illumination. You would have to distinguish by a fixed value, what amount of luminance is part of that lower part and what should not be processed. The edge between the lighter and darker part on the other hand, might not be that sharp in the picture. so you probably get a gradient over some small amount of pixels in y-direction which might make it impossible to remove that edge by adding luminance to the bottom part of the image in a stable way. If it works for one pic, its not said that it does for other pictures.

    My suggestion is to use a 2-picture strategy. Apply an edge detection to the orig image and crop the upper part (remove the bottom part including the unwanted edge between the table and the wall) for the next step. Then, on a copy of the orig image, get the shape of the fluid inside the bottle, maybe by grayscaling and subtracting as I said above. Then remove the background on both pictures and merge them. A typical result would look like:

    Regards,

      Thorsten

    Thanks for helping me!

    Regards,

    Bella

    Sunday, March 25, 2018 6:55 AM