Monday, October 29, 2012

confusion in VL_SLIC

The input image for segmentation:

Way1: Read the img as im2double , so the intensity ranges from 0 to 1. Here, the output superpixels are more regular and spacious.

%Input
img = im2double(imread('Images/2_14_s.bmp'));
regionSize = 30 ;
regularizer = 0.1;

%get the SLIC superpixels
vl_setup
segments1 = vl_slic(single(img), regionSize, regularizer) ;












Way2: Read the img as uint8 , so the intensity ranges from 0 to 255.
Here, the output superpixels are more irregular but tightly fit to the edges.

%Input
img = imread('Images/2_14_s.bmp');
regionSize = 30 ;
regularizer = 0.1;

%get the SLIC superpixels
vl_setup
segments1 = vl_slic(single(img), regionSize, regularizer) ;
I want to know which is the right way? and why this change is affecting the performance?



7 comments:

  1. i think the method 1 is correct. I tried using vl_slic() for an image without vl_setup and i got an error message that it wont accept images which are not double. Moreover the visualization and grouping for method 1 is better than that of method 2.

    ReplyDelete
  2. I have one question since this is concerning VL_SLIC. I am also using the VLFeat package. My question is how do I view the image with superpixels ? I tried imshow(segments) but just get a black image.

    ReplyDelete
    Replies
    1. Hey, sorry , I missed your comment somehow... I hope it is not too late. But I wrote a small code to paint the border pixels of each superpixel to be red.

      Delete
    2. could u pls tell me how to give those red borders? i am also getting black image as an output.

      Delete
  3. Hi Swagatika,

    Thank you so much for this post. It helped me a lot. I was using vl_slic for my study recently but struggled in getting proper result. The different between the "Way1" above and my code is that I used I=double(imread('...')) to read the image. That is to say, in order to get proper result from vl_slic, the DN of input image must be scale to [0,1]. I suspect this is also the reason why "Way2" did not seem right.

    ReplyDelete
    Replies
    1. Yes, double(img) and im2double(img) have different effects even though the datatype is double. Glad I could help. Good Luck!

      Delete