Ask Your Question
0

Superpixel

asked 2018-04-16 10:47:34 -0600

updated 2018-04-17 01:41:47 -0600

berak gravatar image

i've this code where im applying the algorithm slic superpixel on a image. using android studio + opencv contrib .My problem is how can colorise evrey superpixel segments with random colors ' each segment should have a unique colours ' , i tried to manipulate with getlabels , but it will take me too much time ( number of pixel * numberof segments if i use and doble loop ex :

foreach(number_segment) do {
loop all the pixel of the image : 
  if (pixel not existe in the output) && (pixel in the same segments) 
  {
        pixel = random color ;   
        add it to the output 
  }
}

}
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2018-04-17 02:23:31 -0600

berak gravatar image

you probably need to touch each pixel only once:

foreach pixel
    lookup the corresponding label
    calculate a unique color for the label:
         B = (label*123) % 255
         G = (label*237) % 255
         R = (label*91) % 255
edit flag offensive delete link more

Comments

good idea man , but found another trick using the mask i get from getLabelContourMask + find_contours + draw_contours , i will try ur solution , thx buddy

Zouhir_boukhamla gravatar imageZouhir_boukhamla ( 2018-04-18 12:37:53 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2018-04-16 10:45:25 -0600

Seen: 370 times

Last updated: Apr 17 '18