GNUplot solid vertical lines in pdfcairo output - osx-snow-leopard

My Aqua terminal output shows solid lines where I want them: bottom border and x and y grids back.
When I change the output to pdfcairo, I cannot find a way to make the xgrid lines solid. Is this a known issue?
set terminal pdfcairo size 13.5,9.8 solid screen 0,.3 lt 1 lw 2
GNUplot 4.6.1
OSX 10.6.8

If you want solid lines for the grid, I'd use a solid linetype for the grid, rather than relying on terminal settings:
set term pdfcairo size 13.5,9.8 solid
set output 'foo.pdf'
set grid lt 1 lc rgb 'black'
plot sin(x)
As a side note, my
pdfcairo chokes on the screen 0,.3 portion of your set term command. I'm not sure what it's doing there, but I'm pretty sure that it's not what you want.

Related

How to identify that an image comes from a dot matrix printer

I am using Tesseract for OCR character recognition using the Charles Weld C# wrapper. I am pre-processing the images with Open CV.
My issue is that I need to pre-process the image differently if it came from a dot matrix printout. Is there a way, using OpenCV, to tell that the image was scanned from a dot matrix printout?
I have tried blurring the image once and counting the differences using AbsDiff which is the technique I use to detect if an image needs to be despeckled but there is no consitent result that indicates dot matrix.
I had a few thoughts and decided to put them down in ImageMagick but you can equally do this sort of thing with OpenCV and its findContours().
I used this as an input image:
If you erode the black areas a little using morphology (or alternatively dilate the white, it comes to the same thing) each of the dots will become separated from adjacent ones. If you then do a "Connected Component Analysis" you will see that the image has an abnormally large number of very small dots which are roughly the same height as width - characteristic of circles or dots.
Here is the code I used in Terminal to run ImageMagick:
magick dotmatrix.png -threshold 50% -morphology dilate disk:1 \
-define connected-components:verbose=true \
-connected-components 8 -auto-level result.png
The output is this image wherein each detected blob gets a successively brighter shade of white:
More interesting though is the verbose output, which has one line of output per blob detected in the image. It shows lots of small 2x2, 3x2 and similarly sized dots with an area around 7 pixels, circled in red. I would use this as a base for exploring some more...

How to set color of GNUPLOT lines in C

I am writing a program for event driven simulation of elastic collision of spherical balls(in 2D). As a output of the program I am collecting the collision points into a log file(say, data.temp) and plotting them using gnuplot.
I am following the instructions discussed here in this link. My output log file looks like this.
DATA.TEMP(All points are not shown)
20.000000 0.000000
3.535534 0.000000
3.535534 0.000000
45.000000 33.508349
-20.000000 -2.500000
-3.535534 -2.500000
-3.535534 -2.500000
-47.500000 -38.028654
-47.500000 -38.028654
The command used for gnuplot
char* commandForGnuplot[] = {"set title \"Path Plot\"","plot 'data.temp' with linespoints"};
I am able to get a plot like this
I want the paths for different balls to be colored differently. The color should be an input from the user. How can I do this?
Check out gnuplot's docs: http://gnuplot.sourceforge.net/docs_4.2/node62.html
There are some examples in there for defining plot styles. You will have to do some changes in your gnuplot command string -you will probably have to define a style and change your plot command into something like this (just stick your own color in there):
set style line 1 lt rgb "#FF00FF" lw 3 pt 6
plot 'data.temp' with linespoints ls 1

LSCOLORS actual color values

I find that the default colors I get with apps like gnome-terminal are often nearly unreadable. In particular, the bright green for executables is unreadle with a white background.
I can use LSCOLORS to remap executable to be red instead of bright green (or whatever), but what I'd rather do is to make the bright green a shade that's not quite so close to white.
Is there a file somewhere that maps the color numbers in LSCOLORS to RGB values?

loop over array in gnuplot

This question is related to Loop structure inside gnuplot? and the answer there by DarioP.
gnuplot 4.6 introduced the do command. How can I use this to loop over an array of for example files and colors? What is the correct syntax?
colors = "red green #0000FF"
files = "file1 file2 file3"
do for [i=1:3] {
plot files(i).".dat" lc colors(i)
}
If you want to have all files in a single plot, you need to use plot for[... (supported since version 4.4). Looping over several plot commands with do for (supported only since version 4.6) works only in multiplot mode.
The following two solutions both plot all data in one graph, but differ a bit in the iterations.
The first solution uses word to extract a word from a string directly when plotting.
colors = "red green #0000FF"
files = "file1 file2 file3"
plot for [i=1:words(files)] word(files, i).'.dat' lc rgb word(colors, i)
The second solution changes the linetype and then iterates directly over the word list instead of using an index.
colors = "red green #0000FF"
files = "file1 file2 file3"
set for [i=1:words(colors)] linetype i lc rgb word(colors, i)
plot for [file in files] file.'.dat'

There was a function in C to adjust background color? (It was actually a Dos Command)

I am looking for the system function to adjust background color. It was like
system("color",somecolorcodes);
Does anyone know about it?
On Windows Xp or 7!
It's "color XX" where the first X is the background and the second X is the foreground.
The codes are as following:
0 = Black 8 = Gray
1 = Blue 9 = Light Blue
2 = Green A = Light Green
3 = Aqua B = Light Aqua
4 = Red C = Light Red
5 = Purple D = Light Purple
6 = Yellow E = Light Yellow
7 = White F = Bright White
So basically for black text on white ground, you do
system("color 70");
Windows only, tho.
system("cls"); //clears the screen
system("color F0"); //Creates Bright White Background with black text
system("type struct3.c struct2.c"); /*prints the file struct3 and struct2 in the
console*/
system() is a really useful function included in Windows.h library. Apparently we can do many other tasks with this function so I was searching for it when I came across this thread.
Edit:While looking at the commands in command prompt I realized that the above examples are commands in the command prompt and tried using other commands like time, help, del etc in the system() function and figured all the commands that we use in command prompt can be used by System() function.
For that we write the commands in the System() function like below
system("command");
Even though C is case sensitive the command inside system() is not case sensitive like in command prompt.
You can use the SetConsoleTextAttribute function in Windows. This will let you output text in different colors at the same time, while calling "color" doesn't.
There are also others that are less coarse -- search for color in this listing of console functions.
Also, if you're looking for a cross-platform approach take a look, for instance, at this file from Musepack.
A somewhat more portable way of doing this (not DOS or Windows specific) is:
printf("\033[%dm", 40 + color); /* set background color */
The corresponding way to set the foreground color is:
printf("\033[%dm", 30 + color); /* set foreground color */
These work with colors:
0 black
1 red
2 green
3 yellow/brown
4 blue
5 magenta
6 cyan
7 white
These aren't truly portable, either; they work wherever "ANSI control sequences" are implemented in your terminal, terminal emulator, or console.
Under Linux and/or xterm, prefixes 90 (for foreground) and 100 (for background) seem to work, also, perhaps with a slightly different set of colors.

Resources