Example #1
0
void
FilterSharpen::apply()
{
#if defined(HAVE_IPP)
  IppiSize size;
  size.width = src_roi[0]->width;
  size.height = src_roi[0]->height;

  IppStatus status;

  //                                   base + number of bytes to line y              + pixel bytes
  status = ippiFilterSharpen_8u_C1R( src[0] + (src_roi[0]->start.y * src_roi[0]->line_step) + (src_roi[0]->start.x * src_roi[0]->pixel_step), src_roi[0]->line_step,
				     dst + (dst_roi->start.y * dst_roi->line_step) + (dst_roi->start.x * dst_roi->pixel_step), dst_roi->line_step,
				     size );

  if ( status != ippStsNoErr ) {
    throw fawkes::Exception("Sharpen filter failed with %i\n", status);
  }
#elif defined(HAVE_OPENCV)
  if ((dst == NULL) || (dst == src[0])) {
    throw fawkes::Exception("OpenCV-based Sobel filter cannot be in-place");
  }

  cv::Mat srcm(src_roi[0]->height, src_roi[0]->width, CV_8UC1,
               src[0] +
                 (src_roi[0]->start.y * src_roi[0]->line_step) +
                 (src_roi[0]->start.x * src_roi[0]->pixel_step),
               src_roi[0]->line_step);

  cv::Mat dstm(dst_roi->height, dst_roi->width, CV_8UC1,
               dst +
                 (dst_roi->start.y * dst_roi->line_step) +
                 (dst_roi->start.x * dst_roi->pixel_step),
               dst_roi->line_step);

  cv::Mat kernel(3, 3, CV_32F);
  float *kernel_f = (float *)kernel.ptr();
  kernel_f[0] = -0.125; kernel_f[1] = -0.125; kernel_f[2] = -0.125;
  kernel_f[3] = -0.125; kernel_f[4] = 2.0;    kernel_f[5] = -0.125;
  kernel_f[6] = -0.125; kernel_f[7] = -0.125; kernel_f[8] = -0.125;

  cv::Point kanchor(1, 1);

  cv::filter2D(srcm, dstm, /* ddepth */ -1, kernel, kanchor);

#endif

}
Example #2
0
void
FilterHipass::apply()
{
#if defined(HAVE_IPP)
  IppiSize size;
  size.width = src_roi[0]->width;
  size.height = src_roi[0]->height;

  IppStatus status;

  //                                    base + number of bytes to line y              + pixel bytes
  status = ippiFilterHipass_8u_C1R( src[0] + (src_roi[0]->start.y * src_roi[0]->line_step) + (src_roi[0]->start.x * src_roi[0]->pixel_step), src_roi[0]->line_step,
				    dst + (dst_roi->start.y * dst_roi->line_step) + (dst_roi->start.x * dst_roi->pixel_step), dst_roi->line_step,
				    size, ippMskSize3x3 );

  if ( status != ippStsNoErr ) {
    throw fawkes::Exception("Hipass filter failed with %i\n", status);
  }

#elif defined(HAVE_OPENCV)
  cv::Mat srcm(src_roi[0]->height, src_roi[0]->width, CV_8UC1,
               src[0] +
                 (src_roi[0]->start.y * src_roi[0]->line_step) +
                 (src_roi[0]->start.x * src_roi[0]->pixel_step),
               src_roi[0]->line_step);

  if (dst == NULL) { dst = src[0]; dst_roi = src_roi[0]; }

  cv::Mat dstm(dst_roi->height, dst_roi->width, CV_8UC1,
               dst +
                 (dst_roi->start.y * dst_roi->line_step) +
                 (dst_roi->start.x * dst_roi->pixel_step),
               dst_roi->line_step);

  cv::Mat kernel(3, 3, CV_32F);
  float *kernel_f = (float *)kernel.ptr();
  kernel_f[0] = -1; kernel_f[1] = -1; kernel_f[2] = -1;
  kernel_f[3] = -1; kernel_f[4] =  8; kernel_f[5] = -1;
  kernel_f[6] = -1; kernel_f[7] = -1; kernel_f[8] = -1;

  cv::Point kanchor(1, 1);

  cv::filter2D(srcm, dstm, /* ddepth */ -1, kernel, kanchor);
#endif
}