- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I am a new user of IPP(5.1) functions. While performing dilation, I am getting an error: "Stride value is less than the row length". Can anyone please explain how Stride Value is calculated. How is it related to the MaskSize and Step Size used in Dilate Function.
Please help me out.
Thanking You.
Pooja
I am a new user of IPP(5.1) functions. While performing dilation, I am getting an error: "Stride value is less than the row length". Can anyone please explain how Stride Value is calculated. How is it related to the MaskSize and Step Size used in Dilate Function.
Please help me out.
Thanking You.
Pooja
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Pooja,
What is probably happening is the stride is -width. Suppose u have an image with width 320 and height 240, there are two ways in which this image can be stored in memory. First it can be stored like you would expect it to be. Row 1 of size 320 * 4 (assuming ur image is ARGB ) followed by row 2 and row 3 etc etc.. all stored continuously in memory. In that scenario, the stride ( the distance in bytes between two rows ) is 320 * 4.
The second way in which the image can be stored is from bottom to top. That means thats ur image starts with row 1. But row 2 is not after it, but before it. That basically means the stride is -(320 * 4). Some ipp functions do not allow ur image to have a negative stride. So what you need to do is to create a temporary buffer to store the image with a positive stride. Refer to my primitive drawing below.
1. An image with positive stride stored in memory:
row1
row2
row3
row4
..
..
row240
As you can see, the image is store in sequence in memory.
2. An image with negative stride.
row240
row239
..
..
row3
row2
row1
This image is stored bottom to top. But when displayed on the screen, it's from top to bottom.
Here is a piece of c++ code to do the conversion from negative stride to positive stride:
//Assume your image m_image has width m_width and height m_height with 4 channels
//This the the temp buffer that will contain ur image with a positive stride.
BYTE* byTemp = new BYTE[ m_width * m_height * 4 ];
for(int n =0; n < m_height; n++)
{
memcpy( byTemp + ( n * m_width * 4 ), m_image - ( n * m_width * 4 ), m_width * 4 );
}
et voila!
Hope this is useful.
-chetan
What is probably happening is the stride is -width. Suppose u have an image with width 320 and height 240, there are two ways in which this image can be stored in memory. First it can be stored like you would expect it to be. Row 1 of size 320 * 4 (assuming ur image is ARGB ) followed by row 2 and row 3 etc etc.. all stored continuously in memory. In that scenario, the stride ( the distance in bytes between two rows ) is 320 * 4.
The second way in which the image can be stored is from bottom to top. That means thats ur image starts with row 1. But row 2 is not after it, but before it. That basically means the stride is -(320 * 4). Some ipp functions do not allow ur image to have a negative stride. So what you need to do is to create a temporary buffer to store the image with a positive stride. Refer to my primitive drawing below.
1. An image with positive stride stored in memory:
row1
row2
row3
row4
..
..
row240
As you can see, the image is store in sequence in memory.
2. An image with negative stride.
row240
row239
..
..
row3
row2
row1
This image is stored bottom to top. But when displayed on the screen, it's from top to bottom.
Here is a piece of c++ code to do the conversion from negative stride to positive stride:
//Assume your image m_image has width m_width and height m_height with 4 channels
//This the the temp buffer that will contain ur image with a positive stride.
BYTE* byTemp = new BYTE[ m_width * m_height * 4 ];
for(int n =0; n < m_height; n++)
{
memcpy( byTemp + ( n * m_width * 4 ), m_image - ( n * m_width * 4 ), m_width * 4 );
}
et voila!
Hope this is useful.
-chetan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Chetan
Yes I got to know where I was going wrong.
Thanx for ur help.
Regards,
Pooja
Yes I got to know where I was going wrong.
Thanx for ur help.
Regards,
Pooja

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