- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Hi,

I was hoping to get a little help on why the **ippiSampleLine_8uC1R** routine is behaving strangely in my code. I am developing an application for which one of the processing is finding the center of a circle/ellipse in an image. I want to write code to extract line information of fixed length at various angles from the image center. For this, I first wanted to familiarize myself with the use of ippiSampleLine_8uC1R function, and am using a 256x256, 8bit, grayscale, synthetic data (attached .raw) to begin with.

What I observe is that for horizontal and vertical lines (0, 90, 180 & 270 deg) the output is exactly as expected. But for any other angle lines (e.g. 20, 40, 60 deg, etc. in my code), the line profile data extracted from the image seems very "squeezed" (attached excel data sheet), and there are lots of initialized values (0's in my case) at the end of the line buffer. I am comparing the results of the ippiSampleLine_8uC1R function with line profile capabilities of ImageJ (or any other image analysis software can be used).

For my image (attached .bmp), the e.g. 40 deg. line is from -- Start pix: (128, 128) & End pix: (212, 198)

Can anyone offer any ideas why this routine would give such unexpected results? Any help quickly would be deeply appreciated.

Thanks in advance,

GC

/*********************************************************************************************************************************/

Here is the core function. You can find the full working code in the attached circle_detect.c file

/*********************************************************************************************************************************/

void circle_detect( char* img_path )

{

my_img img;

IppiPoint start_pix = {-1, -1};

IppiPoint end_pix = {-1, -1};

void* line_data = NULL;

int num_ele = 0;

int theta_deg = 0;

double theta_rad = 0.0;

int rad_pix = 0;

int img_mid = 0;

int i = 0;

//Create & initialize img

img.size.width = 256;

img.size.height = 256;

img.step = img.size.width * sizeof(Ipp8u);

img.data = ippMalloc(img.size.height * img.size.width * sizeof(Ipp8u));

//Read the image

iret = read_data_raw( img_path, img.data, img.size.width * img.size.height * sizeof(Ipp8u) );

rad_pix = 110;

img_mid = 128;

//Line data: Need memory for at least (num of pixels + 1)

num_ele = rad_pix + 1;

line_data = ippsMalloc_8u(num_ele);

for( theta_deg = 0; theta_deg < 360; theta_deg += 20 )

{

theta_rad = (3.142/180.0) * theta_deg;

start_pix.x = img_mid;

start_pix.y = img_mid;

end_pix.x = (rad_pix * cos(theta_rad)) + img_mid;

end_pix.y = (rad_pix * sin(theta_rad)) + img_mid;

printf("Ang: %d, Start pix: (%d, %d), End pix: (%d, %d)\\n", theta_deg, start_pix.x, start_pix.y, end_pix.x, end_pix.y);

//Line data: Extract line of data from the image

FuncStat = ippsSet_8u( IPP_MIN_8U, line_data, num_ele );

FuncStat = ippiSampleLine_8u_C1R( img.data, img.step, img.size, line_data, start_pix, end_pix );

for(i=0; i

{

printf("%03d, ", ((Ipp8u*)line_data)*); *

}

printf("\\n\\n\\n");

}

ippFree(img.data);

ippsFree(line_data);

img.data = line_data = NULL;

}

/*********************************************************************************************************************************/

Link Copied

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Line lenght in pixels depend on starting and ending points and no more than"max(|pt2.x - pt1.x| + 1, |pt2.y - pt1.y| + 1)". In your case for 40 deg line its length in pixels is 85 so elements in"line_data" with indexes [85,11) stay unchanged. In elements [0,84] stored source image pixels values belonged to the rasterized line.

Igor S. Belyakov

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

40 deg. line is from -- Start pix: (128, 128) & End pix: (212, 198)

so there are about max (212-128 +1, 198-128+1)= 85 points on the line. It is theline as the definition. end_pix.x = (110 * cos(40)) + 128;

but the total lengh of line_data was defined as

//Line data: Need memory for at least (num of pixels + 1)

num_ele =110 + 1;

line_data = ippsMalloc_8u(num_ele);

so other 111-85 pixel on the line_data memorykeepinitial value 0;

rad_pix = 110;

img_mid = 128;

//Line data: Need memory for at least (num of pixels + 1)

num_ele = rad_pix + 1;

line_data = ippsMalloc_8u(num_ele);

for( theta_deg = 0; theta_deg < 360; theta_deg += 20 )

{

theta_rad = (3.142/180.0) * theta_deg;

start_pix.x = img_mid;

start_pix.y = img_mid;

end_pix.x = (rad_pix * cos(theta_rad)) + img_mid;

end_pix.y = (rad_pix * sin(theta_rad)) + img_mid;

Regards,

Ying

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page