- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello
I need to split an RGB or HSV image into the diferent channels.
In openCV I can do this with cvSplit. I "need" to work with the data on each channel separatly. This can be implemented quite easily (the next step if there is no other way), but is there any function that can performe something like an ippiSplit_8u_C3CR?
thanks in advance
Andr Moreira
I need to split an RGB or HSV image into the diferent channels.
In openCV I can do this with cvSplit. I "need" to work with the data on each channel separatly. This can be implemented quite easily (the next step if there is no other way), but is there any function that can performe something like an ippiSplit_8u_C3CR?
thanks in advance
Andr Moreira
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
In ippi there are functions like ippiCopy_<>_C3P3R etc. that split the interleaved planes into separate ones,
and there are ippiCopy_<>_P3C3R that do the opposite thing.
Hope it helps.
Thanks,
Ying
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
There is always a simple answer that I just don't see!
I'm going to check it out, and you probably wont hear from me again ;) (on this topic at least!)
best regards and thanks for the reply!
I'm going to check it out, and you probably wont hear from me again ;) (on this topic at least!)
best regards and thanks for the reply!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
After the wise sugestion of Ying, I tried out ippiCopy_8u_C3P3R() and here is the result.
I'm new to ipp and sometimes I find myself lost in the code. Here goes a simple example that uses ippi for all the operations and openCV for the display.
This code was tested under Linux Fedora Core 3 (compiled with GCC ) and XP (compiled in Visual Studio 6).
I found the original code for ipp and openCv mix in this forum. I don't remember who I got it from, but you can probably still find it here somewhere.
Hope it helps someone!
******************************************************************
#include cv.h>
#include highgui.h>
#include ipp.h>
#include
#include
char name[] = "images/lena.jpg";
// functions defined after main()
void openWindow_8u( Ipp8u *img, IppiSize size, int nChannels, char *name, int wait );
void main(void) {
IppiSize size;
IplImage* img = NULL;
int stride, stride1;
img = cvLoadImage( name, -1 );
size.width = img->width;
size.height = img->height;
Ipp8u *ipprgb = ippiMalloc_8u_C3(size.width, size.height, &stride);
Ipp8u *C1 = ippiMalloc_8u_C1(size.width, size.height, &stride1);
Ipp8u *C2 = ippiMalloc_8u_C1(size.width, size.height, &stride1);
Ipp8u *C3 = ippiMalloc_8u_C1(size.width, size.height, &stride1);
Ipp8u * Q[3] = {C1, C2, C3};
ippiCopy_8u_C3R( img->imageData, stride, ipprgb, stride, size );
ippiCopy_8u_C3P3R(img->imageData, stride, Q, stride1, size);
openWindow_8u( img->imageData, size, 3, "24bit original", 0 );
openWindow_8u( C1, size, 1, "C1", 0 );
openWindow_8u( C2, size, 1, "C2", 0 );
openWindow_8u( C3, size, 1, "C3", 0 );
cvWaitKey(0);
cvDestroyWindow( "24bit original" );
cvDestroyWindow( "C1" );
cvDestroyWindow( "C2" );
cvDestroyWindow( "C3" );
ippiFree( ipprgb ); // memory release with IPP
ippiFree( C1 );
ippiFree( C2 );
ippiFree( C3 );
cvReleaseImage( &img ); // memory release with OpenCV
}
// openWindow_8u used to display IPP images with OpenCV highgui
void openWindow_8u( Ipp8u *img, IppiSize size, int nChannels, char *name, int wait )
{
IplImage *cvImg;
CvSize sizeCv;
Ipp8u *tmp;
int line_type = CV_AA;
sizeCv.width = size.width;
sizeCv.height = size.height;
cvImg = cvCreateImage( sizeCv, IPL_DEPTH_8U, nChannels );
tmp = ippsMalloc_8u( size.width * size.height * nChannels );
if(nChannels == 3) ippiCopy_8u_C3R( img, size.width * nChannels, tmp, size.width * nChannels, size );
if(nChannels == 1) ippiCopy_8u_C3R( img, size.width * nChannels, tmp, size.width * nChannels, size );
cvSetData( cvImg, (void *) tmp, sizeCv.width * nChannels );
cvNamedWindow( name, 1 );
cvShowImage( name, cvImg );
cvDestroyWindow( &cvImg );
}
I'm new to ipp and sometimes I find myself lost in the code. Here goes a simple example that uses ippi for all the operations and openCV for the display.
This code was tested under Linux Fedora Core 3 (compiled with GCC ) and XP (compiled in Visual Studio 6).
I found the original code for ipp and openCv mix in this forum. I don't remember who I got it from, but you can probably still find it here somewhere.
Hope it helps someone!
******************************************************************
#include cv.h>
#include highgui.h>
#include ipp.h>
#include
#include
char name[] = "images/lena.jpg";
// functions defined after main()
void openWindow_8u( Ipp8u *img, IppiSize size, int nChannels, char *name, int wait );
void main(void) {
IppiSize size;
IplImage* img = NULL;
int stride, stride1;
img = cvLoadImage( name, -1 );
size.width = img->width;
size.height = img->height;
Ipp8u *ipprgb = ippiMalloc_8u_C3(size.width, size.height, &stride);
Ipp8u *C1 = ippiMalloc_8u_C1(size.width, size.height, &stride1);
Ipp8u *C2 = ippiMalloc_8u_C1(size.width, size.height, &stride1);
Ipp8u *C3 = ippiMalloc_8u_C1(size.width, size.height, &stride1);
Ipp8u * Q[3] = {C1, C2, C3};
ippiCopy_8u_C3R( img->imageData, stride, ipprgb, stride, size );
ippiCopy_8u_C3P3R(img->imageData, stride, Q, stride1, size);
openWindow_8u( img->imageData, size, 3, "24bit original", 0 );
openWindow_8u( C1, size, 1, "C1", 0 );
openWindow_8u( C2, size, 1, "C2", 0 );
openWindow_8u( C3, size, 1, "C3", 0 );
cvWaitKey(0);
cvDestroyWindow( "24bit original" );
cvDestroyWindow( "C1" );
cvDestroyWindow( "C2" );
cvDestroyWindow( "C3" );
ippiFree( ipprgb ); // memory release with IPP
ippiFree( C1 );
ippiFree( C2 );
ippiFree( C3 );
cvReleaseImage( &img ); // memory release with OpenCV
}
// openWindow_8u used to display IPP images with OpenCV highgui
void openWindow_8u( Ipp8u *img, IppiSize size, int nChannels, char *name, int wait )
{
IplImage *cvImg;
CvSize sizeCv;
Ipp8u *tmp;
int line_type = CV_AA;
sizeCv.width = size.width;
sizeCv.height = size.height;
cvImg = cvCreateImage( sizeCv, IPL_DEPTH_8U, nChannels );
tmp = ippsMalloc_8u( size.width * size.height * nChannels );
if(nChannels == 3) ippiCopy_8u_C3R( img, size.width * nChannels, tmp, size.width * nChannels, size );
if(nChannels == 1) ippiCopy_8u_C3R( img, size.width * nChannels, tmp, size.width * nChannels, size );
cvSetData( cvImg, (void *) tmp, sizeCv.width * nChannels );
cvNamedWindow( name, 1 );
cvShowImage( name, cvImg );
cvDestroyWindow( &cvImg );
}

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