How to create a radial Rainbow colored clone using Inkscape or Affinity? - inkscape

Say I'm using a single colored square - Red. I want to create a circular (clock style) clone of the square. Each clone being a different shade (from red to yellow and back to red, for example.
Say, 24 clones, 15 degree shift, 360 degrees total.
How would I go about accomplishing this?
Maybe a Path Effect might also work in Inkscape. Maybe Rotate Copies or Interpolate?
Used Tiled Clones in Inkscape - didn't work. Tried Using Ctrl-J (Duplicate in Affinity) didn't work. Using most recent versions of Inkscape / Affinity.

Related

How can I emulate this color loop effect?

The title of this question isn't great at explaining what I want to do, so have this gif of the effect I want to emulate: https://i.imgur.com/zRqTSqf.gif (quality of the gif is shite, ik, please bear with me)
I think I need to use the LoopOut() expression for well, the loop, but I don't know how to animate the colors like that. Do I assign different colors in a shape? I'm fairly new to motion graphics, so I'm not familiar with technical terms and all that. Any help/guidance is appreciated!
I would recommend the following:
Create the square shape you are looking for, as a shape layer with a stroke and no fill
Duplicate the shape layer, for example, 4 times
Apply the Trim Paths effect to these layers and distribute it as you wish (for example, if using 4 layers first one from 0 to 25, second one from 25 to 50, third 50 to 75 and fourth one 75 to 100%.
Set a different color for each layer
Create a new Null Object and assign the Slider Control effect to it
Set the Trim Paths Offset property to be driven by the Slider property of the Slider Control (using the pick whip from each layer)
Animating the Slider property of the Slider control in the Null Object, driving the color of all the sides.
Use masks to fix the possible glitches on the vertices and to make it look nice
you can then alt-click on the stopwatch of the Slider property inside the Slider Control of the Null Object and type LoopOut(). Make sure that the first and last keyframes are correct so once the looping is activated the end is the same as the beginning and you should be good to go!
I think this should more or less point you in a possible way of solving it, let me know if you need more help!
In Illustrator, draw a square with a stroke, no fill, and rotate it 45 degrees. And on a separate layer, draw 6 triangles in the desired colours. Example below:
Save as an AI file. Import this artwork into After Effects, setting Import Kind to Composition.
Set the composition length to 4 seconds.
Set the track matte for the triangles layer to the Alpha Matte of the square layer. (#1 in the above)
Open the rotation property of triangles, set a key frame on frame 1, then go to 4 seconds, and set a key frame of 1 rotation. (#2 in the above)
Precompose these layers, then apply a CC Light Burst 2.5 effect for the glow.
Result is as below.

Best way to draw boxes around pure red areas of an image?

I have an image with various odd shapes (such as circles and squares) which are coloured pure red (rgb(255, 0, 0) exactly). I want to draw boxes around these shapes, but to do that I need the coordinates of each corner from each box. This is the part I am having difficulty with.
I basically want to go from this:
To this:
I have tried many different ways to achieve this, including parsing the y-axis until I find a shape and boxing it that way, starting from the very corners of the image and moving towards the middle (both methods of which don't work well for multiple shapes) and using external packages such as an OpenCV.
I could use OpenCV to achieve this, but given the constraints I was hoping there was a way to do it which doesn't require an external package.
Can anyone with a bit more machine vision experience point me in the right direction please?
First, use the Hoshen-Kopelman algorithm to determine the connected clusters of pixels with the given criteria (being red), then all you have to do is find their min/max regions (on x and y axes) to wrap them with a rectangle.

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.)

How can I detect TV Screen from an Image with OpenCV or Another Library?

I've working on this some time now, and can't find a decent solution for this.
I use OpenCV for image processing and my workflow is something like this:
Took a picture of a tv.
Split image in to R, G, B planes - I'm starting to test using H, S, V too and seems a bit promising.
For each plane, threshold image for a range values in 0 to 255
Reduce noise, detect edges with canny, find the contours and approximate it.
Select contours that contains the center of the image (I can assume that the center of the image is inside the tv screen)
Use convexHull and HougLines to filter and refine invalid contours.
Select contours with certain area (area between 10%-90% of the image).
Keep only contours that have only 4 points.
But this is too slow (loop on each channel (RGB), then loop for the threshold, etc...) and is not good enought as it not detects many tv's.
My base code is the squares.cpp example of the OpenCV framework.
The main problems of TV Screen detection, are:
Images that are half dark and half bright or have many dark/bright items on screen.
Elements on the screen that have the same color of the tv frame.
Blurry tv edges (in some cases).
I also have searched many SO questions/answers on Rectangle detection, but all are about detecting a white page on a dark background or a fixed color object on a contrast background.
My final goal is to implement this on Android/iOS for near-real time tv screen detection. My code takes up to 4 seconds on a Galaxy Nexus.
Hope anyone could help . Thanks in advance!
Update 1: Just using canny and houghlines, does not work, because there can be many many lines, and selecting the correct ones can be very difficult. I think that some sort of "cleaning" on the image should be done first.
Update 2: This question is one of the most close to the problem, but for the tv screen, it didn't work.
Hopefully these points provide some insight:
1)
If you can properly segment the image via foreground and background, then you can easily set a bounding box around the foreground. Graph cuts are very powerful methods of segmenting images. It appears that OpenCV provides easy to use implementations for it. So, for example, you provide some brush strokes which cover "foreground" and "background" pixels, and your image is converted into a digraph which is sliced optimally to split the two. Here is a fun example:
http://docs.opencv.org/trunk/doc/py_tutorials/py_imgproc/py_grabcut/py_grabcut.html
This is a quick something I put together to illustrate its effectiveness:
2)
If you decide to continue down the edge detection route, then consider using Mathematical Morphology to "clean up" the lines you detect before trying to fit a bounding box or contour around the object.
http://en.wikipedia.org/wiki/Mathematical_morphology
3)
You could train across a dataset containing TVs and use the viola jones algorithm for object detection. Traditionally it is used for face detection but you can adapt it for TVs given enough data. For example you could script downloading images of living rooms with TVs as your positive class and living rooms without TVs as your negative class.
http://en.wikipedia.org/wiki/Viola%E2%80%93Jones_object_detection_framework
http://docs.opencv.org/trunk/doc/py_tutorials/py_objdetect/py_face_detection/py_face_detection.html
4)
You could perform image registration using cross correlation, like this nice MATLAB example demonstrates:
http://www.mathworks.com/help/images/examples/registering-an-image-using-normalized-cross-correlation.html
As for your template TV image which would be slid across the search image, you could obtain a bunch of pictures of TVs and create "Eigenscreens" similar to how Eigenfaces are used for facial recognition and generate an average TV image:
http://jeremykun.com/2011/07/27/eigenfaces/
5)
It appears OpenCV has plenty of fun tools for describing shape and structure features, which appears to be mainly what you're interested in. Worth a look if you haven't seen this already:
http://docs.opencv.org/modules/imgproc/doc/structural_analysis_and_shape_descriptors.html
Best of luck.

How best to approach a localised thresholding opengl function

I would like to take a photo of some text and make the text easier to read. The tricky part is that the initial photo may have dark regions as well as light regions and I want the opengl function to enhance the text in all these regions.
Here is an example. On top is the original image. On bottom is the processed images.
[edited]
I have added in a better example picture of what is happening. I am able to enhance the text, but in areas where I have no text, this simple thresholding is creating speckled noise (image bottom left).
If I wind back the threshold, then I lose the text in the darker region (bottom right).
At the moment, the processed image only picks up some of the text, not all the text. The original algorithm I used was pretty simple:
- sample 8 pixels around the current pixel (pixels about 4-5 distant away seem to work best)
- figure out the lightest and darkest pixels from this sample
- if the current pixel is closer to the darkest threshold, then make black, and vice versa
This seemed to work very well for around text, but when it came to non-text, then it provided a very noisy image (even when I provided an initial rejection threshold)
I modified this algorithm to assume that text was always close to black. This provided the bottom image above, but once again I am not able to pull out all the text features I want.
Before implementing this as a program, you might want to take source photo and play with it in a GIMP or another editor to see what you can do.
One way to deal with shadows is to run high pass filter before thresolding.
This is how you do it in image editor (manually, without "highpass" filter plugin):
1. Convert image to grayscale and save it to "layer_A"
2. make a copy of "layer_A" into "Layer_B"
3. Invert colors in "Layer_B"
4. Gaussian blur "Layer_B" with radius that is larger than largest feature you want to preserve. (blur radius larger than letter)
5. Merge "Layer_A" with "Layer_B" where result = "Layer_A" * 0.5 + "Layer_B" * 0.5.
6. Increase contrast in resulting image.
7. Run thresold.
In opengl it'll be done in same fashion (and without multiple layers)
It won't work well with strong/crisp shadows (obviously), but it will exterminate huge smooth shadows that occurs due to page being bent, etc.
The technique (high pass filter) is frequently used for making seamless textures, and you should be able to find several such tutorials and additional info with google (GIMP seamless texture high pass or GIMP high pass).
By the way, if you want to improve "readability", then you might want to keep it grayscale (while improving contrast) instead of converting it to "black and white" (1 bit color). Sharp letter edges make text harder to read.
thanks for your help.
In the end I went for quite a basic approach.
Taking a sample of 8 nearby pixels, determining the max and min. Determined the local threshold (max - min). Then
smooth = dot(vec3(1.0/3.0), smoothstep(currentMin, currentMax, p11).rgb);
smooth = (localthreshold < threshold) ? 1.0 : smooth;
return vec4(smooth, smooth, smooth, 1);
This does not show me the text nicely in both the dark and light region, which is the ideal, but it nicely cleans up the text in the lighter region.
Mike