Search code examples
regionhslhalcon

Halcon - Subtract regions


I'd need to subtract one region from another. I found how to combine two, but cannot figure out how to subtract one from another..

What I want to do is this:

I have a Image splitted in its H L S channels.

I want the Region of the L Channel between 100 and 200, but only where the S channel is above 50.

How can this be done?


Solution

  • Try something like this:

    read_image(Image, './tire.jpg')
    
    access_channel(Image, ImageRed, 1)
    access_channel(Image, ImageGreen, 2)
    access_channel(Image, ImageBlue, 3)
    
    trans_from_rgb(ImageRed, ImageGreen, ImageBlue, ImageH, ImageL, ImageS, 'hls')
    
    threshold(ImageS, ImageSRegion, 50, 255)
    reduce_domain(ImageL, ImageSRegion, ImageLReduced)
    threshold(ImageLReduced, ImageLRegion, 100, 200)