Community
cancel
Showing results for 
Search instead for 
Did you mean: 
seaviewfc
Beginner
63 Views

question about ipp reshape image

Hi,

I'm new for ipp. There are too many pages for user's manual, and less samples step by step. Sorry about that!

In matlab, there is a function called 'reshape', is there similar function in ipp? For example:
I have an image, how can I convert selected ROI to an array.

Here is an image: pixel values show in following:

1,0,0,0,2,0,0,1,0,9
0,0,2,0,2,0,1,1,1,0
6,0,1,0,1,1,0,1,1,1
1,0,1,2,3,4,0,0,0,1
2,0,5,6,7,8,0,0,0,2
0,0,2,0,1,1,0,1,0,1
6,0,0,0,0,3,0,0,3,0

and which function allow me copy from top-left x = 3, y = 4 to bottom-right x=6,y=5 to an array, then I can have a array like this:
nm = [1,2,3,4,5,6,7,8];

Thank you very much!
Regards
Chao

0 Kudos
3 Replies
Vladimir_Dudnik
Employee
63 Views

Hi Chao,

for IPP it still image Copy operation. You can consider your output array as an image. So, in you case it should be call to(in case of Ipp8u single channel image)ippiCopy_8u_C1R(src + 4*10 + 2, 10, dst, 4, roi), where
src is pointer to your input image
4*10+2 moves pointer to the beginning of your ROI,
10 is input image step (number of bytes between adjacent image rows),
dst is pointer to your output array,
4 is output image step,
roi is IppiSize roi = {2,4} - size of your ROI

Regards,
Vladimir

seaviewfc
Beginner
63 Views

Hi Vladimir,

Thank for reply.

I see your idea, but I have two questions about that.

1. The output dst is a two dimension matrix, it is not an array. if I still need an array do I have to convert it by setting value one by one?

2. I can convert it to an array by assigning pixels by "for loop", instead of using image Copy operation. My question is which method is fast in your experience?

Regards
Chao
Vladimir_Dudnik
Employee
63 Views

Chao,

Physically, processor see memory as 1D array of bytes. Your programmayconsider data as a 2D or 3D array or even more complicated waybut this is logical level.

Basically, what I'm saying - there is nodifference in memory layout between

[1 2 3 4]
[5 6 7 8]

and

[1 2 3 4 5 6 7 8]

and so you can use ippiCopy function (which is faster for big enough arrays).

Regards,
Vladimir