SVG Rendering Error in Batik/Eclipse - eclipse

I have been using Batik with Eclipse for a year, and came across a rendering error I cannot seem to shake. I have reduced it to a minimal set and placed the image on flickr:https://www.flickr.com/photos/dattatreya/15019722962/. I expect to see a solid wide red line crossing a solid yellow wide line. You can see the artifact (error) in the thin yellow line that crosses the red band (along the top edge of the yellow band). I see similar errors in many images I draw.
The SVG code generated by Batik is below. Interestingly, that code was incorrectly rendered by both Safari and Chrome (but not by IE) some time ago, but right now, all browsers seem to work correctly. Only Batik does not.
This could be a Batik bug; if so, I hope they fix it soon!
SVG code generated by Batik for the image:
========================================================
<svg stroke-dasharray="none" shape-rendering="auto"
xmlns="http://www.w3.org/2000/svg" font-family="&apos;Dialog&apos;"
text-rendering="auto" fill-opacity="1" contentScriptType="text/ecmascript"
color-interpolation="auto" color-rendering="auto"
preserveAspectRatio="xMidYMid meet" font-size="12" fill="black"
xmlns:xlink="http://www.w3.org/1999/xlink" stroke="black"
image-rendering="auto" stroke-miterlimit="10" zoomAndPan="magnify"
version="1.0" stroke-linecap="square" stroke-linejoin="miter"
contentStyleType="text/css" font-style="normal" stroke-width="1"
stroke-dashoffset="0" font-weight="normal" stroke-opacity="1">
<!--Generated by the Batik Graphics2D SVG Generator-->
<defs id="genericDefs"/>
<g>
<g fill="red" stroke="red">
<path d="M-106.066 106.066 L893.934 1106.066 L1000 1212.1321 L1212.1321 1000 L1106.066 893.934 L106.066 -106.066 L0 -212.132 L-212.132 0 L-106.066 106.066 Z"
stroke="none"/>
</g>
</g>
<!--Generated by the Batik Graphics2D SVG Generator-->
<defs id="genericDefs"/>
<g>
<g fill="yellow" stroke="yellow">
<path d="M106.066 1106.066 L1106.066 106.066 L1212.1321 0 L1000 -212.132 L893.934 -106.066 L-106.066 893.934 L-212.132 1000 L0 1212.1321 L106.066 1106.066 Z"
stroke="none"/>
</g>
</g>
<!--Generated by the Batik Graphics2D SVG Generator-->
<defs id="genericDefs"/>
<g>
<defs id="defs1">
<clipPath clipPathUnits="userSpaceOnUse" id="clipPath1">
<path d="M500 287.868 L287.868 500 L287.868 500 L500 712.1321 L500 712.1321 L712.1321 500 L500 287.868 Z"/>
</clipPath>
</defs>
<g fill="red" stroke="red">
<path d="M-106.066 106.066 L893.934 1106.066 L1000 1212.1321 L1212.1321 1000 L1106.066 893.934 L106.066 -106.066 L0 -212.132 L-212.132 0 L-106.066 106.066 Z"
clip-path="url(#clipPath1)" stroke="none"/>
</g>
</g>
</svg>
=================================================================

This is not a Batik bug. It is a "problem" pretty much all graphics libraries will have whether they are SVG renderers or otherwise. It is still visible when I render this in Chrome - it's just less noticeable.
What your SVG does is:
draw a red stripe on the bottom.
then draw a yellow stripe across it
finally it draws a red square to cover the intersection of the two stripes to make it look like the red square is on top.
The reason you are seeing a barely visible yellow line is due to antialiasing. The renderer is drawing partially yellow pixels at the edge of the yellow strip to make the edge of the stripe look more smooth. When you draw the red square on top, some of the yellow pixels are going to remain visible and/or the partially red pixels being drawn on top are letting the yellow show through. The result is a yellowish strip of pixels at the edge.
I guess the question is "why are you not just drawing the red stripe on top of the yellow?" Doing that would fix your problem.

Related

Problem importing Bezier curve coordinates in Matlab from .svg

I'm trying to draw Bezier curves from an .svg file using Matlab.
I've opened the .svg in a text editor. One of the lines I'm trying to draw is this one: <path fill="none" stroke="#000000" stroke-miterlimit="10" d="M117.125,310.375c0-77.729,80.738-140.625,180.515-140.625"/>
If I understand things correctly, the start point is (x , y) (117.125 , 310.375), the first control point is (0 , -77.729), the second control point is (80.738 , -140.625) and the end point is (180.515 , -140.625). However this doesn't seem to be correct as the output I get is far from the actual curve.
How it looks:
How it's supposed to look:
The start and end points are all right, but the control points seem wrong... Matlab draws the correct points, I've checked them (the axis may look a bit weird but it's correct)
I'm using the code from Mathworks (https://blogs.mathworks.com/graphics/2014/10/13/bezier-curves/). It needs the start point pt1, the control points pt2 and pt3 and the end point pt4.
The code works, the problem seems to lie with the coordinates of the points.
I've tried entering the coordinates above in an online .svg editor (it only supports integers so every coordinate is positive here, the control points shouldn't 'pull' the curve that much but the output is the same as the one obtained with MatLab): http://www.useragentman.com/tests/textpath/bezier-curve-construction-set.html#path=M%20297%2C%20169%20C%2058%2C%200%2C%2098%2C%2077%2C%2098%2C%20192&imageURL=http://www.useragentman.com/tests/textpath/images/grid.png
Here is the entire file, created with Illustrator CS6:
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 16.0.4, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="595.28px" height="841.89px" viewBox="0 0 595.28 841.89" enable-background="new 0 0 595.28 841.89" xml:space="preserve">
<line fill="none" stroke="#000000" stroke-miterlimit="10" x1="116.083" y1="608.292" x2="117.125" y2="310.375"/>
<path fill="none" stroke="#000000" stroke-miterlimit="10" d="M117.125,310.375c0-77.729,80.738-140.625,180.515-140.625"/>
<path fill="none" stroke="#000000" stroke-miterlimit="10" d="M297.64,169.75c58.959,0,98.652,77.535,98.652,192.708"/>
<line fill="none" stroke="#000000" stroke-miterlimit="10" x1="396.292" y1="362.458" x2="387.958" y2="653.083"/>
</svg>
I'm really hoping someone can help me with this. I'm new to .svg
Thanks to #Paul LeBeau for the link. It turns out ".svg"s are case sensitive and that a C is not a c... You learn things every day. The website I looked at for help before I posted didn't mention this.
2, 3 and 4 are all relative to 1 in this case. I added a few lines of code to my script so that 2 = 1 + 2relative, 3 = 1 + 3relative and 4 = 1 + 4relative, and it works!
Now I can finally clean up my code to do both the lines and the paths at the same time and draw my racing line.
NB: I know the points are reversed for the purple curve. This is due to Illustrator not being able to do a curve "the other way round" without switching the points...

Unicode character to represent "fullscreen"?

I'm sort of surprised that this doesn't exist given the sheer number of arrow-like symbols in Unicode. Have I missed something? Or is there a character that looks similar to a fullscreen icon?
There is also U+26F6 "SQUARE FOUR CORNERS" ⛶ that looks somewhat similar to this image
that you've linked. No idea what the symbol was originally supposed to stand for, though... I'm also not sure that it actually does look like four corners in all fonts, maybe it's just the font of my particular browser.
If you search for expand from the link Hans Passant commented above you'll get the below
⛶ like what Youtube uses does appear among the result
Another suggestion:
U+21F1 ⇱ North West Arrow to Corner
U+21F2 ⇲ South East Arrow to Corner
The North East and South West versions don't exist but you can rotate or mirror the available ones to create the remaining two corners. But two corners are already enough to represent a fullscreen action, you don't need to fill all four corners
Other alternatives
U+2725 ✥ FOUR CLUB-SPOKED ASTERISK
U+21F9 ⇹ LEFT RIGHT ARROW WITH VERTICAL STROKE
U+21FC ⇼ LEFT RIGHT ARROW WITH DOUBLE VERTICAL STROKE
U+2921 ⤡ NORTH WEST AND SOUTH EAST ARROW
U+1F542 🕂 CROSS POMMEE (needs some modification or a special font to make the heads more arrow-like)
↔↕ (use alone or drawn onto each other to get a cross with arrows)
⤡⤢
⇳
⤄
🡤🡥🡦🡧
🡴🡵🡶🡷
🢄🢅🢆🢇
🢔🢕🢖🢗
Some examples with arrows
Here is another variation used by the player in vtvgiaitri.vn
I guess they can be made from ◣ U+25E3 Black Lower Left Triangle and ◥ U+25E5 Black Upper Right Triangle or some of the triangles like below
◸ U+25F8 Upper Left Triangle
◹ U+25F9 Upper Right Triangle
◺ U+25FA Lower Left Triangle
◿ U+25FF Lower Right Triangle
𝅊 U+1D14A Musical Symbol Triangle Notehead Left White
𝅋 U+1D14B Musical Symbol Triangle Notehead Left Black
𝅌 U+1D14C Musical Symbol Triangle Notehead Right White
𝅍 U+1D14D Musical Symbol Triangle Notehead Right Black
𝅎 U+1D14E Musical Symbol Triangle Notehead Down White
𝅏 U+1D14F Musical Symbol Triangle Notehead Down Black
𝅐 U+1D150 Musical Symbol Triangle Notehead Up Right White
𝅑 U+1D151 Musical Symbol Triangle Notehead Up Right Black
There are also ⤧⤨⤩⤪⤭⤮⤯⤰, unfortunately they don't have the double-head arrow version, but a simple solution like ⤪⤭ might work
You can draw on shapecatcher to find more relevant solutions or look for more arrows on
https://en.wikipedia.org/wiki/Arrow_(symbol)#Arrows_in_Unicode
https://en.wikipedia.org/wiki/Arrows_(Unicode_block)
https://en.wikipedia.org/wiki/Supplemental_Arrows-A
https://en.wikipedia.org/wiki/Supplemental_Arrows-B
https://en.wikipedia.org/wiki/Supplemental_Arrows-C
FWIW, as of this writing, YouTube is using an SVG for its "SQUARE FOUR CORNERS" icon; here's the code:
<svg height="100%" version="1.1" viewBox="0 0 36 36" width="100%">
<path d="m 10,16 2,0 0,-4 4,0 0,-2 L 10,10 l 0,6 0,0 z"></path>
<path d="m 20,10 0,2 4,0 0,4 2,0 L 26,10 l -6,0 0,0 z"></path>
<path d="m 24,24 -4,0 0,2 L 26,26 l 0,-6 -2,0 0,4 0,0 z"></path>
<path d="M 12,20 10,20 10,26 l 6,0 0,-2 -4,0 0,-4 0,0 z"></path>
</svg>
You can use some of these Unicode chars:
⌈⌊⌊⌋
「」
┘┌└ ┐
╬
⛶
╭ ╮╯╰
with <sub> or <sup> + overlapping
Or arrows:
⇱⇲
⇳⇖⇗⇘⇙⇕⇔↔↕↖↗↘↙ (and other arrows...)
Here's the classic Windows "full screen" icon: 🗖
https://www.fileformat.info/info/unicode/char/1f5d6/index.htm
I'm currently using ⇱︎, which isn't great, but sort of gets the idea across. I've also played around with "merging" characters like this:
<div style="position:relative; display:inline-block;">
<div>↖</div>
<div style="position:absolute; top:0;">↗</div>
<div style="position:absolute; top:0;">↘</div>
<div style="position:absolute; top:0;">↙</div>
</div>
Which produces this:
But it'd be much nicer if there was a single character for that sort of shape.
<sup>⇱</sup><sub>⇲</sub>
⇱⇲

Dividing Ground-penetrating radar profile through image processing

Please look at the attached image. It is a GPR profile and using image processing techniques, I am trying to divide this image into 3 zones by labeling with colors the whole image on the top:
when parabolas in the image are very clear and distinct with high pixel values - green zone/ line at the top
when parabolas in the image are blurred but visible - yellow zone
when parabolas are distorted or when not parabolas are present - red zone
What techniques should I use? What's the best approach to solve it?
I have tried various techniques but not with success in every case, because, as you can in the following image, sometimes the parabolas are too close to one another and identifying them is becoming an issue.
A sample of how I want to zone it: https://www.dropbox.com/s/9zm9epgf0gt7591/sample.png?dl=0
One of the tried code: simplest one.
clear all
clc
%read png image
H=imread ('origpng.png');
%convert to gray scale
I = rgb2gray(H);
I(I>150)=0;I(I<100)=0;
figure,imshow(I)
J=I;
J=255-J;
figure, imshow (J)
J(J<255)=0;
figure,imshow (J)
Your question is not very clearly posed, but I spent some time on it and felt like sharing my thoughts. I am not preteding for an instant that this is anywhere near a complete, or rigorous answer - just some musings that might give you some ideas. Also, I use ImageMagick, but if you have and know Matlab, you should use that - I am not suggesting you switch tools.
First, I did a Canny Edge detection like this:
convert http://i.stack.imgur.com/XITAE.png -canny 0x1+15%+50% canny.jpg
that gives me this:
I then "squash" that down till it is just 1 pixel high, which effectively totals up and averages all the columns - I make it 10 pixels high here so you can see it. Where it is white, there are lots of parabolas, elsewhere there are fewer.
Then I stretch that back up to the full height of the original image and blur it a bit - note that everything up to the following image is just one line of "code":
convert http://i.stack.imgur.com/XITAE.png -canny 0x1+15%+50% -resize x1! -normalize -resize 827x310! -blur 0x11 -colorspace gray mask.png
I then use the above as an opacity mask for a red image the same size as your original like this:
convert -size 827x310! xc:red mask.png -compose copy-opacity -composite colouredmask.png
Then I took your original image and coloured it with yellow like this by first creating a yellow image and then blending it onto your image and then I blended the red image from above on top of that:
convert -size 827x310! xc:yellow yellow.png
convert http://i.stack.imgur.com/XITAE.png yellow.png -compose colorize -composite colouredmask.png -compose overlay -composite result.png
giving
Obviously you can set different parameters and use different thresholds and things, but it kind of heads towards the sort of thing you are aiming it.
So the entire process is:
# Make mask of peaky areas - line 1
convert http://i.stack.imgur.com/XITAE.png -canny 0x1+15%+50% -resize x1! -normalize -resize 827x310! -blur 0x11 -colorspace gray mask.png
# Colour mask with red - line 2
convert -size 827x310! xc:red mask.png -compose copy-opacity -composite colouredmask.png
# Tint original image with yellow and then overlay semi-transparent red area
convert -size 827x310! xc:yellow yellow.png
convert http://i.stack.imgur.com/XITAE.png yellow.png -compose colorize -composite colouredmask.png -compose overlay -composite result.png
Notes
Squashing pixels... sorry for confusing you with my terminology! Basically, when I squash the pixels down to a single row, you need to imagine dropping a brick on the top of the image and flattening it down to just one pixel tall. So, essentially, you draw an imaginary line underneath the image and then you work across the image totalling up the number of WHITE (i.e. edge) pixels in each vertical column. Columns that have more white pixels will add up to larger numbers. Columns that have no white pixels will add up to zero. Once you have got the totals for each column, you find the highest total - let's say it is 32 and then you multiply all totals by 255/32 so that everything is normalized to 255, or white. Now the squashed strip represents the edge energy in each column. And I then use that as the opacity for the red when I overlay - so columns with more white edges in the Canny image will show up with more red in the result.
Let's demo what happens if I squash down to 10 pixels wide and 1 pixel high before scaling back up to the original size - basically it means that my resulting mask will have only 10 possible values (or columns) columns and that each column will be a single constant brightness. I'll put the Canny image underneath so you can see that the brightness of the squashed strip represents the edge energy:
convert http://i.stack.imgur.com/XITAE.png -canny 0x1+15%+50% -resize 10x1! -normalize -scale 827x310! mask.png
If you want to introduce another colour, you need to work out what your algorithm is for controlling where that colour should appear. You then do exactly the same thing again - you make a mask that is light where you want that colour in your output image and dark where you don't want that colour. Then you use that mask as the opacity for your new colour (as I did at the line labelled line 2 above) and then you overlay it like I did in the last line of my code above.

Imagick6 "-gravity SouthEast" while using -draw 'image [...]' failed

I have switch from Imagick version 5 to Imagick version 6 and noticed the following
While using the command:
convert -gravity SouthEast -draw 'image Over 0,0 0,0 overlay.png'
In version 5 the overlay.png is being added the bottom right corner (SouthEast) as expected!
But version 6 of ImageMagick failed and the position of the overlay.png is at the top left corner!
The command is used in typo3 "imgResource.params" http://docs.typo3.org/typo3cms/TyposcriptReference/Functions/Imgresource/Index.html
But I think this has nothing to do with the CMS, but with compatibility of im5 and im6
Anyone knows how to solve this...?
You can use this command instead:
convert background.jpg foreground.jpg -gravity SouthEast -compose Src_Over -composite output.jpg
So if this is our background:
and this is our foreground:
we get the following result:
Actually, I think he looks better on the other side of the image, but flopped to still face inwards :-)
convert background.jpg \( tiger.png -flop \) -gravity SouthWest -compose Src_Over -composite out.jpg
Updated Answer
Sorry to hear that the command doesn't work inside typo3. There is another version here that may work for you...
First get the width and height of the background and foreground images - I guess there is a way to do this in typo3, but I'll do it like this:
identify -format "%w %h" background.jpg
906 603
So the background is 906 px wide and 603 px high, and
identify -format "%w %h" tiger.png
258 296
the tiger is 258 px by 296. Then we can overlay using geometry like this, by subtracting the width and height of tiger from the width and height of the background to give an offset from top left of image:
convert background.jpg tiger.png -geometry +648+307 -composite out.png
which gives the same effect as gravity southeast. Maybe that will get you there...
Updated One Last Time
This one must get you there... just put the correct offsets in your original draw command rather than relying on gravity. So the first two numbers are the x,y offsets of the top left corner of the overlaid image from the top left corner of the background image, and the second x,y pair are the offsets of the bottom right corner of the overlaid image. So basically,
x1,y1 = width background - width overlay, height background - height overlay
x2,y2 = width background, height background
convert background.jpg -draw 'image Over 648,307 906,603 tiger.png' out.jpg

Javafx Scene Builder Linear Gradient is what

is there any one knows what on earth is the linear gradient?
How Can I use the right panel, especially the four scroll bar, to adjust the fill of the triangle on the left to make the triangle upper half white but down half black?
Is there any document to help train people how to use this? I am really sorry I can not find it.
Thanks in advance!
General info on linear gradients
The linear-gradient documentation is at:
JavaFX CSS reference.
It is a w3c color stop form.
javadoc of how linear gradients work in JavaFX.
Because the linear gradient in JavaFX CSS is the same syntax as w3c CSS, any tutorial on CSS linear gradients returned by google will probably apply to JavaFX CSS.
Feedback email address for JavaFX documentation is: javasedocs_us#oracle.com
Linear Gradients and SceneBuilder
Scene Builder uses FXML to represent linear gradients. It can also use render linear gradients from CSS, though the gradient editor in SceneBuilder works to edit the FXML representation of gradients and not the CSS representation.
Here is a result of loading the following FXML file into SceneBuilder:
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.paint.*?>
<?import java.lang.*?>
<?import javafx.scene.shape.*?>
<Polygon xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1">
<points>
<Double fx:value="-50.0" />
<Double fx:value="40.0" />
<Double fx:value="50.0" />
<Double fx:value="40.0" />
<Double fx:value="0.0" />
<Double fx:value="-60.0" />
</points>
<fill>
<LinearGradient startX="0.5" startY="0" endX="0.5" endY="1">
<stops>
<Stop color="WHITE" />
<Stop color="BLACK" offset="1.0" />
</stops>
</LinearGradient>
</fill>
</Polygon>
Scroll Bar Settings
The scroll bar settings are marking the proportional co-ordinates of the start and end properties of the linear gradient. These co-ordinates from a directional vector (line) along which colors in the linear gradient change according to the defined stops. The bars work as follows:
left bar: startY
top bar: startX
right bar: endY
bottom bar: endX
For the above fill, it means start at the top center and travel to the bottom center, varying the color from white to black as you go, so it's a straight top to bottom vertical transition.
Discrete Gradients
If you didn't want a smooth gradient, but instead wanted an abrupt one, then add more stops, for example:
<fill>
<LinearGradient endX="0.5" endY="1" startX="0.5" startY="0">
<stops>
<Stop color="WHITE" />
<Stop color="WHITE" offset="0.5"/>
<Stop color="BLACK" offset="0.5" />
<Stop color="BLACK" offset="1.0" />
</stops>
</LinearGradient>
</fill>