Inkscape: radial opacity gradients on jpgs - inkscape

I'm trying to create an image where I'd like to include part of a jpg image in the following way: I'd like to have the "outer" part of the jpg at the fringes, so that it is opaque on the edges and transparent in the middle (where the main part of my image is). I've tried the following:
1. Adding a radial opacity gradient to the jpg itself as if it were a vector-based object.
2. Creating an Inkscape object with an analagous gradient and then doing a Clip>Set with the jpg.
Neither of these worked (obviously). Is there a way to do this in Inkscape? all of my attempts have either done nothing, or have only succeeded in changing the opacity of the image uniformly (without a gradient).

The feature you want is called Masking, you can find it right below Clip in the menu in Inkscape.
The darker or more transparent the mask object is, the more it hides from what is below. So you need a gradient that goes from black in the center to white at the outer perimeter.
The rest works just like clipping.

Related

How to use OpenCV to process the example picture

I need some suggestion in processing the following image.
Basically, I want to remove the background which is a dark red table and leave the filter (a white background and a gray spot in the middle)
This picture is taken by the camera. I think in a real experiment, the background may not be a single color but the type of filter always be the same.
edit:
The desired object could be anywhere in the picture.
The background could be anything not just the dark red
But the object is always white
I am using OpenCV to process this image, any suggestion about what types of method of OpenCV should be used for this example.
Thanks

Inkscape: How to have many shapes with exactly the same gradient

I created a flowchart in InkScape in which each shape is filled with a linear gradient.
Some shapes share the same gradient tones but when I created them via copy&past did not know that gradients could be transformed during edit, I thought that copy&pasting a shape simply copy the entire object and each colors.
Anyway, it resulted in shapes that changes background gradient during re-positioning. After several searches I discovered that this is caused by a wrong position of "Gradient Editor Tool" of each one. In other words I moved objects but start/end of each gradient remained in place.
Please, how to quickly reposition gradient direction/start/end of each shape, maybe centering it on each one? I would avoid to manually reposition each one...
Thanks
Inkscape provides a toggle button to move the gradients along with the objects.
Activating this button during any coying or moving carries the gradient with it to the new location. (Actually it copies the gradient.)

Finding individual center points of circles in an image

I am using open CV and C++. I have a completely dark image which has 3 colored points on it. I need their center coordinates. If I have only one colored point in the dark image, it will automatically display its center coordinate. However,if I take as input the dark image with the 3 colored points,my program will make an average if those 3 coordinates and return the center of the 3 colored points together,which is my exact problem. I need their individual center coordinates.
Can anyone suggest a method to do that please. Thanks
Here is the code http://pastebin.com/RM7chqBE
Found a solution!
load original image to grayscale
convert original image to gray
set range of intensity value depending on color that needs to be detected
vector of contours and hierarchy
findContours
vector of moments and point
iterate through each contour to find coordinates
One of the ways to do this easily is to use the findContours and drawContours function.
In the documentation you have a bit of code that explains how to retrieve the connected components of an image. Which is what you are actually trying to do.
For example you could draw every connected component you will find (that means every dot) on it's own image and use the code you already have on every image.
This may not be the most efficient way to do this however but it's really simple.
Here is how I would do it
http://pastebin.com/y1Ae3e2V
I'm not sure this works however as I don't have time to test it but you can try it.

ideas for removing background fringes using opencv

basically i wrote a code that had two images. a reference img and a background img. So far i have successfully found the matching image by using feature recognition. Then i rotated it and resized it to look identical as the reference image. The only problem left is the fact that the image as some of the background image on the fringes of the object. This image has been appropriately cropped so i just need to work with the image below. The most obvious answer that first came to me was perhaps use a edge detection algorithm (canny) and use that to give me a clue on where the background may lie. However since the images itself could technically be anything i feel like there would be lots of noise and various unusual errors so if possible i would rather not want to take that path. I also saw the backgroundsubtraction MOG but it seemed like that works for videos and not for single stilled image. In case i was wrong i tried the following code but had 0 effect:
BackgroundSubtractorMOG bs_mog(3, 4, 0.8);
Mat foreground_mog;
bs_mog (cropped_img, foreground_mog, -1.0);
Perhaps i am doing it wrong. So my thought is other than edge detection and if backgroundsubtractorMOG is only for moving images are there any other ideas or options i can look into to remove the fringe background image (i want to turn it all into just white)
thank you in advance for your ideas and comments
EDIT:
well i unerstand the logic already posted by others but i am unsure what the best way to make a mask for this bottom image would be. It is important to note that the image can technically be anything. Not necessary round in shape. Also due to changes in the algorithm the shape must be resized after the object is separated from the background. This means i can't use my reference image to just make a mask and use that mask on this image due to the difference in size.
Segmentation could work. Try cvgrabCut() with a customized mask.
Set as background all pixels very close to borders. (red in image below)
Set as foreground the center area of your image. (green in image below)
Any intermediate pixels set them to probably foreground. (gray in image below)

Extracting an object from a low contrast background

I need to extract an object from an image where the background is almost flat...
Consider for example a book over a big white desktop.. I need to get the coordinates of the 4 corners of the book to extract a ROI.
Which technique using OpenCV would you suggest? I was thinking to use k Means but I can't know the color of the background a priori (also the colors inside the object can be vary)
If your background is really low contrast, why not try a flood fill from the image borders, then you can obtain bounding box or bounding rect afterwards.
Another option is to apply Hough transform and take intersection of most outer lines as corners. This is, if your object is rectangular.