Place Graphviz xlabel under the edge - graphviz

In Graphviz, are there options for:
placing xlabel under an edge?
setting transparency for an edge?

You can set transparency on (any?) color by specifying the color as an RGBA value, like so:
edge [color="#ff000080" penwidth=2] // note translucent color

Related

Algorithm for smart floodfill in raster image

I'm trying to implement flood fill method for raster image.
For center pixels it's easy and works correct, but the problem is to fill pixels near border, which have different color.
For example, if draw Black figure on White background, some border pixels will have kind of gray color instead of black (for smoothing).
Image editors (like paint.net) during floodfill fixes it changing these pixels to some middle color between old and new one. Here I filled figure in red color, and gray pixels became in red gradient
I need to know method or algorithm how gray pixels became in kind of color to fill (here it's red, but can be any) using RGB pixel manipulation.
Thanks for any help.
So, for similar effect like in example we just need to use & operation between old and new color.
For RGB color:
resultColor.R = (byte)(oldColor.R & newColor.R);
resultColor.G = (byte)(oldColor.G & newColor.G);
resultColor.B = (byte)(oldColor.B & newColor.B);
If RGB color is Int number:
resultColor = oldColor & newColor;
It will not be exactly same color as in example below but pretty similar.

Setting the background to transparent using GIMP

Using GIMP 2, I have an image of a grey chair on a white background, as below:
I now want to set the background to transparent. Therefore, I decided to use GIMP's "Color To Alpha" tool. So, I told it to set all pixels which are white (255, 255, 255) to transparent, as below:
This did set all white pixels to transparent. However, it also set the grey pixels on the chair to be partially transparent, as below:
So when I export this image and place it in front of a background, there is no white box around the chair -- but the background partially shows through the chair.
What am I doing wrong?
First, this question is offtopic here, and should be on https://graphicdesign.stackexchange.com .
Second, it is trivial enough just to answer: the color to alpha plug-in is not there to turn a single color, as seem on the image, to transparency: it is a sophisticated plug-in that will remove one color of your image in a way that, if you lace the new image over a background of the same color the color you removed, you get the original image back.
Thus, in your case, it removed the "whiteness" of your chair, transforming all pixels to different opaque shades of black - so that when placed over white, you get the original image.
To simply remove the white, you have to cick on the Select By Color tool (by default th 5th icon on the toolbox), click on the white background to have it selected, and then just edit->cut. (It won't work if your image layer does not have transparency to start with - if that is the case, prior to edit->cut do Layer->Transparency->Add Alpha Channel).
If you get aliased borders, then, after edit>cut, but prior to dismissing your selection, you can do Select->Border... by 1 or 2px, and then use the color to alpha filter with White on this selection.
For more information on Color to Alpha, I have this other answer its use and comparison with edit-cut here: https://graphicdesign.stackexchange.com/questions/28058/gimp-color-to-alpha-is-not-selectable/28097#28097
Just use a selection to restrict the action of Color to alpha where it matters: backgroundand edge pixels:
Select background with fuzzy select
Select>Grow by one pixel so that the selection ofverlaps the edge pixels
Color>Color to alpha

Gnuplot: set size ratio -1 and <lrtb>margin 0 not working?

Using Gnuplot, I want to plot a PNG as a background image to a PDF file, which I later would like to plot curves onto. The aspect ratio of the axes should be 1, such that the image is not distorted. Furthermore, there should be no white borders around the image in the PDF file. Currently, I use:
set terminal pdf color solid
set output "input.pdf"
unset xtics
unset ytics
unset border
set size ratio -1
set lmargin 0
set rmargin 0
set tmargin 0
set bmargin 0
plot "input.png" binary filetype=png w rgbimage notitle
This leaves large white margins at the left and right borders.
When I omit set size ratio -1, there are no margins, but the image is distorted.
When I replace set terminal pdf color solid with set terminal pdf color solid size <width>, <height>, inserting the width and height of the PNG, I get the desired output, i.e. no margins and image retains its original aspect ratio. Unfortunately, in my workflow, this would require parsing and passing these values to Gnuplot automatically, which seems cumbersome.
Is there any reason why setting the margins to 0 does not work together with setting the aspect ratio to 1?
Do you have other solutions that do not require to pass the image dimensions to Gnuplot?

velocity.js // animating svg fill from transparent to color

It obviously does not work :
Without specyfying the start color, it translates from white to the color specified.
If the start/end colors are specified with hex, same thing
If colors are specified with rgba values, with alpha at 0 for the start color, and alpha at 1 for the end color, there is no transition, it immediately get the end color
If anyone has clues or alternatives on this one (the point is to animate the svg fill color from transparent to color, don't care about velocity), that'd be great
Animate fill with hex values and fill-opacity from 0 to 1 paralelly.

Color approximation

Let's suppose we have a regular RGB image. Now we would want to approximate the color of each individual pixel of our source image with a color out of a small set of colors.
For example, all tones of red should be converted to that specific red out of my set of colors, same goes for green, blue, etc.
Is there any elegant way/algorithm to achieve this?

Resources