fuy34 / superpixel_fcn

[CVPR‘20] SpixelFCN: Superpixel Segmentation with Fully Convolutional Network
Other
392 stars 80 forks source link

Can I get a certain number of superpixels in all picture? #27

Closed yelanyelan closed 3 years ago

yelanyelan commented 3 years ago

Can I control all images to output the same number of superpixels?(Those photos have the same resolution.) According to the traditional algorithm, such as SLIC, I can get a same number of superpixels in some photos. And, further, can we control a certain number of pixels in a superpixel? I not sure it we can do it with spixel_fcn? Thank u very much.

fuy34 commented 3 years ago

Hi,

Our method can control the expected number of superpixels to some extent.

The way is to first turn off the merging process, and then, control the image size and the size of the grid cell. For example, if we train the model with 16 x 16 cell size, and the input image is 480 x 320, we will get about 600 superpixels. And if we want more, for example, 1200 superpixels, we can enlarge the image to 960 x 640 and then resize the output assignment map back to 480 x 320.

However, we cannot precisely control the number of superpixels. First, if the desired number can not be obtained by the image size divides the grid cell size, there is no way. For instance, for the same example above, it is impossible to get 333 superpixels. And second, even if the number can be obtained, some superpixels may have no pixel associated (determined by the network assignment).

To precisely control the number, we have to do some additional post-processing. For example, generating slightly more superpixels than we want, and merge the small superpixels until reach the desired number.

I hope it helps.

yelanyelan commented 3 years ago

Actually what I want to do is: dividing a series of photos(allowing resizing) into the same number of superpixels, rather than a specific non-divisible certainly number of superpixels. Thanks to ur answer and I probably understand how to do it. Best wishes.