LSCOLORS actual color values - rgb

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?

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

DOSBox autoexec menu design

I'm trying to make a (somewhat) stylish DOS menu as a present for my father.
I was able to get the whole menu system to work, but I wanted to gussy it up with some box drawing characters and, possibly, colored text.
In this YouTube video, the user shows an example of what I'm trying to do (example at the 5:00 mark), but doesn't explain how those characters are being rendered. In the Notepad document, it is displayed as goofy characters.
Do I need to save the file with a special type of encoding? Can it only be done in Notepad (I'm using TextEdit on Mac)? Can someone provide an example menu that can be added to DOSBox's [autoexec] config?
Also, I'm not sure if it is possible, but how can the text color/background color be changed? When running DOSBox initially, it shows their welcome screen with a blue background and box drawing characters, so I would think all of that is possible.
I tried using escaped unicode characters and I tried using a capital-E acute (as shown in the linked video), but they just render funky stuff when run in DOSBox.
The discrepancy in characters is a result of different code pages being used in character rendering. English-speaking Windows uses ANSI code page 1252 (otherwise known as Latin-1), while DOS uses OEM code page 437, or IBM-PC.
The codepage that Windows uses will vary based on your system language, so you many need to experiment to find the correct characters, but basically, find the character you want to print in 437 (say ╔, which is 200) and then in your code use the 1252 version (where 200 is È). Then save the file in ANSI encoding.

combing red green and blue files to make a .ppm file in a C programme

i currently have 3 files, a red, a green and blue component file(s) and i need to code a program that will combine these three files into a single readable ppm file. how/whats the best route for me to take for this? thanks
Sam
You mean, like this: rgb3toppm.c?
If you're doing this as an exercise, you can look at the source code for that utility. If you just need the utility, you'll probably find rgb3toppm in your netpbm distribution.

How to set terminal background color on linux terminal without using ncurses?

I've wrote a simple console program in C which uses ANSI escape codes to color its text.
Is there a way to temporarily set the background of the whole terminal to black and the default font color to light gray? Can this be reverted after the program ends?
I'd prefer to avoid using ncurses.
Probably the simplest way to go is to set the background colour of your text with ANSI:
For instance using:
echo -e "\e[37m\e[41m"
will give you blue text on a red background (you can use this to test the effect in dramatic, easy to see colours).
Whereas
echo -e "\e[97m\e[40m"
will set the foreground to white and the background to black for the duration of your program.
If you find that you're getting a kind of ugly transition zone between your background colour and the terminal's just print a sufficient number of newlines to wipe the whole screen.
To use this in C, you'll obviously want printf instead of echo.
The wiki page on ANSI escape codes has additional information.
How to do this depends on the terminal the user is using. It may be ANSI, it may be VT100, it might be a line printer. ncurses abstracts this horror for you. It uses a database of information about how to talk to different kinds of terminal (see the contents of $TERM to see which one you are currently using) normally stored in /lib/terminfo or /usr/share/terminfo.
Once you look in those files, you'll probably want to reconsider not using ncurses, unless you have specific requirements to avoid it (embedded system with not enough storage, etc.)

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