Check if a color filter is applied on an image using OpenCV - opencv

I have the following images.
Color filter vs No filter
The top image is the normal image, while the bottom image was applied a red filter on it. Is there any way to detect if a color filter was applied on an image using OpenCV?
I'm quite new to OpenCV, so I don't really know a lot about manipulating color with OpenCV.

Related

GPUImage - Custom Histogram Generator

I'm trying to use GPUImage to implement a histogram into my app. The example project on the GPUImage github called FilterShowcase comes with a good histogram generator, but due to the UI design of the app I'm making I'll need to write my own custom graph to display the histogram values. Does anyone know how can I get the RGB values from the GPUImageHistogramFilter so I can pop them into my own graph?
The GPUImageHistogramFilter produces a 256x3 image where the center 256x1 line of that contains the red, green, and blue values for the histogram packed in the RGB channels. iOS doesn't support a 1-pixel-high render framebuffer, so I have to pad it out to three pixels high.
The GPUImageHistogramGenerator creates the visible histogram overlay you see in the sample applications, and it does that by taking in the 256x3 image and rendering an output image using a custom shader that colors in bars whose height depends on the input color value. It's a quick, on-GPU implementation.
If you want to do something more custom that doesn't use a shader, you can extract the histogram values using a GPUImageRawDataOutput and pulling out the RGB components of the center 256x1 line. From there, you could draw the rest of your interface overlay, although something done using Core Graphics may chew a lot of processing power to update on every frame.

Background subtraction with reflective material

I am using background subtraction method to detect moving objects. Because their type in my experiment is reflective material object, so it causes difficulty for detecting. How could I resolve it?
Thank you!
EDIT: I'm using Background subtraction MOG2 (in OpenCV). OpenCV version is 3.10
EDIT 1: Updated the result when apply to HSV colour space
Step 1: Convert to HSV colour space
Step 2: Apply MoG2
I'm assuming your camera is non-moving, you know the background model and you are using something like MOG detector. The simplest approach is to use color space that separates luminance from hue and saturation - one such example is HSV color space. OpenCV provides cvtColor function to convert i.e. form BGR (default) to HSV color space. Later you can use just hue and saturation channel to avoid influence of value variations (light). This however won't work for extremely shiny objects, like plastic or shiny metal lit by sunlight that appears to be white to the camera.
Another way you can deal with this problem is to use motion tracking - i.e. optical flow. If you are really interested and want to get more into details, I can refer you to some specific papers.

Apply GPUImage filter to part of video

I want to add two filters to one video, so half of the screen shows one filter and the other half another filter. But they should be applied to the same video, just on different parts of the screen.
Is it possible to do with GPUImage? If not, what are the alternatives?
While still a little experimental, the Swift version of GPUImage has a new capability for masking filter operations on images.
Most filters (but not all at present) can use the mask property to provide an image for masking the regions of the image you want to apply a filter to. The mask image uses the alpha channel to denote the regions you want to mask off, with opaque areas being filtered and transparent ones unfiltered.

Blending artifacts in OpenCV image stitching

I am using OpenCV to blend a set of pre-warped images. As input I have some 4-channel images (*.png or *.tif) from where I can extract a bgr image and an alpha mask with the region related to the image (white) and the background (black). Both image and mask are the inputs of the Blender module cv::detail::Blender::blend.
When I use feather (alpha) blending the result is ok, however, I would like to avoid ghosting effects. When I use multi-band, some artifacts are appearing on the edges of the images:
The problem is similar to the one raised here, and solved here. The thing is, if the solution is creating a binary mask (that I already extract from the alpha channel), it does not work for me. If I add padding to the ovelap between both images, it takes pixels from the background and messes up even more the result.
I guess that probably it has to do with the functions pyrUp and pyrDown, because maybe the blurring to create the Gaussian and Laplacian pyramids is applied to the whole image, and not only to the positive alpha region. In any case, I don't know how to fix the problem using these functions, and I cannot find another efficient solution.
When I use another implementation of multiresolution blending, it works perfectly, however, I am very interested in integrating the multi-band implementation of OpenCV. Any idea of how to fix this issue?
Issue has been already reported and solved here:
http://answers.opencv.org/question/89028/blending-artifacts-in-opencv-image-stitching/

OpenCV Floodfill - Replace pixel color with transparent pixel

I'm trying to do Floodfill on UIImage and ended up using OpenCV framework. I can replace the color with a solid color by defining the color as cv::Scalar(255,0,0). However I want the floodfill selection to be transparent.
I don't know how I can define a transparent color in OpenCV and to the best of my knowledge it's not possible and the only option is to merge the image to a transparent background. Again it doesn't make much sense to Floodfill using a solid color and then merge it with a transparent layer as the result will be the original image with solid color in the fill areas.
Please correct me if I'm wrong.
Much appreciate your help in solving this.
Cheers
You cannot define a transparent color in OpenCV since it currently do not support image with alpha channel.
However, there exists a tricky solution. You may first refer to this question to create a mask of your floodfill area. Then you can easily calculate the alpha channel from this mask.

Resources