- Код: Выделить всё
void TForm1::BubbleContours(Graphics::TBitmap &bmp, Graphics::TBitmap &outputBmp)
{
IplImage *image = TBitmapToIplImage(&bmp);
IplImage* laplace = 0;
IplImage* colorlaplace = 0;
IplImage* planes[3] = { 0, 0, 0 };
// Laplacian
if( !laplace )
{
for(int i = 0; i < 3; i++ )
{
planes[i] = cvCreateImage( cvSize(image->width,image->height), 8, 1 );
}
laplace = cvCreateImage( cvSize(image->width,image->height), IPL_DEPTH_16S, 1 );
colorlaplace = cvCreateImage( cvSize(image->width,image->height), 8, 3 );
}
cvCvtPixToPlane( image, planes[0], planes[1], planes[2], 0 );
for(int i = 0; i < 3; i++ )
{
cvLaplace( planes[i], laplace, 3 );
cvConvertScaleAbs( laplace, planes[i], 1, 0 );
}
cvCvtPlaneToPix( planes[0], planes[1], planes[2], 0, colorlaplace );
colorlaplace->origin = image->origin;
// Contours
IplImage *edge = cvCreateImage( cvSize(image->width,image->height), IPL_DEPTH_8U, 3 );
IplImage *convertedImage = cvCreateImage( cvSize(image->width,image->height), IPL_DEPTH_8U, 3 );
cvCanny(convertedImage, edge, 50, 200, 3 ); //error here
IplImageToTBitmap(edge, &outputBmp);
}