Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.
6704 Discussions

Understanding the output of ippiLabelMarkers

rogene
Beginner
1,042 Views
Hey there,

Could someone please give me some intuition for what the LabelMarkers algorithm is doing? This output doesn't make sense. Attached are two files. The first is the grayscale image that I used as the input to the LabelMarkers algorithm. The second image is the graycoded output from the algorithm.

Not much different if I choose a different norm.

Any insight?

Thanks!

-R




0 Kudos
11 Replies
rogene
Beginner
1,042 Views

Does anyone know what algorithm was implemented in ippiLabelMarkers?

I am trying to understand the output. I was expecting an image that looked a bit more like the ouput from the Canny method.

ex,http://www.mathworks.com/products/demos/image/watershed/ipexwatershed.html

or read: http://www.eecs.berkeley.edu/Research/Projects/CS/vision/grouping/papers/mafm-cvpr08.pdf

user error? it's always possible. here is code:

// create grayscale from orig rgb image
int graystride;
Ipp8u* ippGrayimage = ippiMalloc_8u_C1(width, height, &graystride);
ippiRGBToGray_8u_C3C1R(ippImage, stride, ippGrayimage, graystride, roi);

// get size and allocate memory for buffer
int buffersize;
ippiLabelMarkersGetBufferSize_8u_C1R(roi, &buffersize);
Ipp8u* buffer = ippsMalloc_8u(buffersize);

//compute labels - I don't know how many labels in advance, so choose max minto allowfull range
int minLabel = 1;
int maxLabel = 254;
int numLabels;
ippiLabelMarkers_8u_C1IR(ippGrayimage, graystride, roi, minLabel, maxLabel, ippiNormL1, &numLabels, buffer);

// create bitmap to write to file
Bitmap^ newImage = gcnew Bitmap(width, height, PixelFormat::Format24bppRgb);
int x = 0;
for (int i = 0; i < height; i++) {
for (int j = 0; j < graystride; j++) {
int c = *(ippGrayimage + x);
if (j < width) {
Console::WriteLine(c);
float a = 255.0f/(float)(numLabels + 1);
int b = (int) ((float)c * a);
Color color = Color::FromArgb(b, b, b); // turn the label into gray color
newImage->SetPixel(j,i,color);
}
x++;
}
}
return newImage; // and print to file to examine

The runtime output contains a '3', two '2's, and the rest were 0 or 1. It is attached as an image in the previous posting.

What does LabelMarkers do under the hood?

Thanks!

-Rogene
0 Kudos
rogene
Beginner
1,042 Views

Has anyone here successfully used the output of LabelMarkers as input to either of the IPP Segmentation algorithms?





0 Kudos
simbalee
Beginner
1,042 Views
Quoting - rogene

Has anyone here successfully used the output of LabelMarkers as input to either of the IPP Segmentation algorithms?






Seems no one understand how that thing works.
It seems to me that Intel guys are all genius and happily assume that users (of the thing they made) are all the same genius as they are.
It was a very happy experience to use IPP. Things were done so quickly and elegantly. Now it has become a huge jungle. Black dirty swamp everywhere. The manuals are remotely helpful. To use IPP with these manuals is the same thing to fly a F22 with a mechanical handbook. I dare you to use it.
0 Kudos
rogene
Beginner
1,042 Views
Quoting - simbalee

Seems no one understand how that thing works.
It seems to me that Intel guys are all genius and happily assume that users (of the thing they made) are all the same genius as they are.
It was a very happy experience to use IPP. Things were done so quickly and elegantly. Now it has become a huge jungle. Black dirty swamp everywhere. The manuals are remotely helpful. To use IPP with these manuals is the same thing to fly a F22 with a mechanical handbook. I dare you to use it.

I know what you mean. I have not found this to be the most helpful or friendly of forums.

Sadly for Intel, if I get too frustrated, I will find another way to get the job done, and my company will not be buying. We don't need screaming fast libraries so much as we need clarity wrt the algorithms. I am only using their library because my boss asked me to evaluate it.

0 Kudos
Igor_B_Intel1
Employee
1,042 Views
Before invoking this function foregroundand background markers in input image should be separated. To do thisuse somemorphology operationslike reconstruction-based opening and closing can be used.

Example of image segmentation with using of this function can be found in image-codecsPicnic sample.

0 Kudos
elhefe38
Beginner
1,042 Views
Quoting - rogene

I know what you mean. I have not found this to be the most helpful or friendly of forums.

Sadly for Intel, if I get too frustrated, I will find another way to get the job done, and my company will not be buying a zillion copies of the IPP library for their servers. We don't need screaming fast libraries so much as we need clarity wrt the algorithms. I am only using their library because my boss asked me to evaluate it.


If you have a *real* problem, I strongly encourage you to file an issue to the official support. Usually you get an answer to your question in a relatively short time...
And believe me, you can find a lot worse than IPP in terms of documentation ! ;)
0 Kudos
Ying_H_Intel
Employee
1,042 Views
Quoting - rogene

Does anyone know what algorithm was implemented in ippiLabelMarkers?

I am trying to understand the output. I was expecting an image that looked a bit more like the ouput from the Canny method.

ex,http://www.mathworks.com/products/demos/image/watershed/ipexwatershed.html

or read: http://www.eecs.berkeley.edu/Research/Projects/CS/vision/grouping/papers/mafm-cvpr08.pdf

user error? it's always possible. here is code:

// create grayscale from orig rgb image
int graystride;
Ipp8u* ippGrayimage = ippiMalloc_8u_C1(width, height, &graystride);
ippiRGBToGray_8u_C3C1R(ippImage, stride, ippGrayimage, graystride, roi);

// get size and allocate memory for buffer
int buffersize;
ippiLabelMarkersGetBufferSize_8u_C1R(roi, &buffersize);
Ipp8u* buffer = ippsMalloc_8u(buffersize);

//compute labels - I don't know how many labels in advance, so choose max minto allowfull range
int minLabel = 1;
int maxLabel = 254;
int numLabels;
ippiLabelMarkers_8u_C1IR(ippGrayimage, graystride, roi, minLabel, maxLabel, ippiNormL1, &numLabels, buffer);

// create bitmap to write to file
Bitmap^ newImage = gcnew Bitmap(width, height, PixelFormat::Format24bppRgb);
int x = 0;
for (int i = 0; i < height; i++) {
for (int j = 0; j < graystride; j++) {
int c = *(ippGrayimage + x);
if (j < width) {
Console::WriteLine(c);
float a = 255.0f/(float)(numLabels + 1);
int b = (int) ((float)c * a);
Color color = Color::FromArgb(b, b, b); // turn the label into gray color
newImage->SetPixel(j,i,color);
}
x++;
}
}
return newImage; // and print to file to examine

The runtime output contains a '3', two '2's, and the rest were 0 or 1. It is attached as an image in the previous posting.

What does LabelMarkers do under the hood?

Thanks!

-Rogene


Hi Rogene,


In fact,the image with labeled markers is used as the seed image for future segmentation (i.e watershed segmentation).

There are two outputs from thefunction ippiLabelMarkers
1) numLabels
Itreturnthe number of detected marker . You can take it asthe number of detected regions.
Could you please check the value in it after you call the function?

2) The image of marker. Itwill beused as seeds of future sgements.
It returnsa initialsegment image.We call it as markers "image'. In this "image", each connectedset of non-zero image pixels is treated as a region.
Each adjacent region was labeled with same value (marker number). Theseregion are separated by zero pixels from each other.

For example, you have grayscale image (left matrix) as input, if minLabel=1, maxLabel=254;
If ippiLabelMarkers found there are 5 region in belowimage, then it will return numLabels=5 and
meanwhile, return the labeled result as right matrix.
225 0 0 123 2441 0 022

170 0 0 0 167 ->1 0 0 0 2

0 0 189 0 0 0 03 0 0

200 0 0 0 2194 0 0 0 5

if minLabel=63, maxLabel=235;then labeled result is

63 0 0 64 64

63 0 0 0 64

0 0 65 0 0

66 0 0 0 67

So the marker image looks a grayscale image, but the value of each points doesn't mean grayscale value, it is number of label.
I guess, as your minLabel=1, thenthe first region is labled as 1, the second region is labeled as 2. That's why your output image looks dark.

IPPprovidesample code todemontrates the LabelMarkers functions usage at the file:
ipp-samplesimage-codecsuicsrcapplicationpicnicsrcsegmentation.cpp.

You can download IPP sample packagefrom http://www3.intel.com/cd/software/products/asmo-na/eng/219967.htm

Hope itcan help.

Regards,
Ying

0 Kudos
rogene
Beginner
1,042 Views
Before invoking this function foregroundand background markers in input image should be separated. To do thisuse somemorphology operationslike reconstruction-based opening and closing can be used.

Example of image segmentation with using of this function can be found in image-codecsPicnic sample.


Igor,

Thanks much - I will look into the morphology operations in section 8.

0 Kudos
Igor_B_Intel1
Employee
1,041 Views
Quoting - rogene
int col = 0;
for(k = 0; k < (params.measure ? params.rep : 1); k++)
{
ippiLabelMarkers_8u_C1IR((Ipp8u*)mar1,mar1.Step(),roi,1,254,ippiNormL1,&col,flbuf);
}

And I am trying to understand why this iteration over k is necessary.

Cheers!

-Rogene

Rogene,
This iteratrion doneto measure performance only. No need to do in your application.

Igor
0 Kudos
rogene
Beginner
1,041 Views
Quoting - rogene
int col = 0;
for(k = 0; k < (params.measure ? params.rep : 1); k++)
{
ippiLabelMarkers_8u_C1IR((Ipp8u*)mar1,mar1.Step(),roi,1,254,ippiNormL1,&col,flbuf);
}

And I am trying to understand why this iteration over k is necessary.

Cheers!

-Rogene

Rogene,
This iteratrion doneto measure performance only. No need to do in your application.

Igor

Thanks, Igor. I appreciate the clarification.
0 Kudos
Ying_H_Intel
Employee
1,041 Views

Greetingrogene,

Yes, before the lablemarker,to dopre-processing canprovide a goodmarker placeforexact segmentation.You may consider toimplementsome pre-processing methods based on your image model, likedo threshold (IPP provideThreshold functions inIPPI, you may usethem seperately)or simple segment, i.e by color if RGB image.

Thanks
Ying
0 Kudos
Reply