How to control halftone dots and ink density in Ghostscript - ghostscript

How to control halftone dots and ink density in Ghostscript? I'm using a Epson SC T-7270PS model and I'm trying to print without any RIP software and it has failed so far. Does anyone know how to control the screen frequency and ink density settings in Ghostscript? Is it even possible? Thanks.

You can use the sethalftone operators in PostScript to set the halftone screen. See section 7.4 of the 3rd edition PLRM.

Related

How to display B&W pixel images on a TI-84 graphic calculator (Non-CE version)

I've seen images online of people able to display black & white pixel images on their TI brand graphing calculators:
I've tried googling around but I can only find instructions for color images for the TI-84 Plus CE calculator, and nothing for the older black and white screened calculators (Ex TI-84 plus which is what I have).
How do I display a black and white image on an older non-color TI graphing calculator?
Are there ways to import and display an image? Or do you draw it using individual points for each pixel? (I've seen instructions for making images using the graphing function, but I'm not sure if these images were created this way). Or is there a different way to do it?
First, you need your calculator, the standard a to mini b usb cable, a Windows or Mac computer, TI Connect Software, and an editing software such as photoshop.
Open your picture in your editing software. Desaturate the image, resize the image to 192 by 128, bring up the contrast to maximum, and save the image.
Go to this website or any website to pixelate the image.
https://www.imgonline.com.ua/eng/8bit-picture.php
Go to adjustment levels on your editing software to make the blacks truly black and the whites truly white.
Copy your image and open TI Connect. Plug in your calculator and turn it on. Paste your picture and save it. Press the Send Picture button, remember the file name you choose.
To open the picture make sure your drawing is clear and your axes are off, go to draw, choose RacallPic in the STO menu, enter the number of the file name you saved it on and you have your picture. Hope this helps.

Ghostscript command for finding the number of colors used for each page in pdf file

I'm new to GhostScript. Can you let me know the Ghostscript command for finding the number of colors used for each page in pdf file. I need to parse the results of this command from java program
There is no such Ghostscript command or device. It would also be difficult to figure out; so much depends on what you mean. Do you intend to count the colour of each pixel in every image for example ? Which colour spaces are you interested in ? What about ICCBased colour spaces, do you want the component values, or the CIE values ?
[edit]
Yeah there's no Ghostscript equivalent, I did say that.
You wuold have to intercept every call to the colour operators, examine the components being supplied and see if they were no black and white. For example, if you set a CMYK colour with C=M=Y=0 and K!=0 then its still black and white. Similar arguments apply for RGB, CIE and ICC colour spaces.
Now I bet ImageMagick doesn't do that, I suspect it simply uses Ghostscript to render a bitmap (probably RGB) and then counts the number of pixels of each colour in the output. Image manipulation tools pretty much all have to have a way to do that counting already, so its a low cost for them.
Its also wrong.
It doesn't tell you anything about the original colour. If you render a colour object to a colour space that is different to the one it was specified in, then the rendering engine has to convert it from the colour space it was in, to the expected one. This often leads to colour shifts, especially when converting from RGB to CMYK but any conversion will potentially have this problem.
So if this is what ImageMagick is doing, its inaccurate at best. It is possible to write PostScript to do this accurately, with some effort, but exactly what counts as 'colour' and 'black and white' is still a problem. You haven't said why you want to know if an input file is 'black and white' (you also haven't said if gray counts as black and white, its not the same thing)
I'm guessing you intend to either charge more for colour printing, or need to divert colour input to a different printer. In which case you do need to know if the PDF uses (eg) R=G=B=1 for black, because that often will not result in C=M=Y=0 K=1 when rendered to the printer. Not only that, but the exact colour produced may not even be the same from one printer to another (colour conversion is device-dependent), so just because Ghostscript produced pure black doesn't mean that another printer would.
This is not a simple subject.

Windows font rendering

I am writing an application which gets the data stream going to the printer (from Redmon) as input. The data stream has text rendered as monochromatic bitmap which printer would use to print it on the paper. I plan to parse this data stream and understand the text going to the printer. My application would parse the data coming from any windows application and going to the printer.
The way I parse the data stream is by matching the pixel information (byte by byte) and if there is an exact match then I can uniquely identify a character. For this I am assuming that all windows applications use same windows renderer to render the font in terms of pixel. Hence I would always get the same sequence of bytes for a particular character from any application if these application(including the ones based on java) use same font and font size for printing their text. Is this a correct assumption or do windows provide various options to applications for rendering the text for printing ?
Also is there a library which I can use for doing character recognition using monochromatic bitmap data ?
NOTE: The printers I am using are ESC/POS compatible printers. The printer driver for these printers send the data to be printed as a monochromatic bitmap.
I'm not familiar with ESC/POS printers, but if you can guarantee the driver always renders text as monochrome bitmaps, your chances of characters being identical for the same font and size are very high, but they are not 100%. First, you also need to account for rotation, scaling and shearing. You would need to consider the entire transformation matrix, not just the font size.
There are at least two other failure points I can think of: 1) Text overlaid with transparencies and 2) if the machine has alternate fonts installed with the same names. For example, common fonts like Helvetica can be obtained from many sources and the characters will not be identical between them. A third possible failure is an application that ignores the fact that a printer is monochromatic and prints in color or grayscale. Converting color or grayscale to monochrome will produce different bitmaps for different colors.
As for OCR software, Wikipedia has a nice comparison chart of OCR SDKs.

Advice on using OCR on an image of a blackboard

I'm trying to get an image of a blackboard readable by OCR. Naturally, most OCR software doesn't like dirty images. What image processing should I try to put the image through to clean the image up?
Have you tried the OCR software yet? It's likely that the OCR software is well suited to reading what's essentially already a black and white image.
However, if you were required to do so you could try to:
Threshold the image.
Essentially take a greyscale version of the image and turn it into black / white pixels
Perform Binary Dilation to grow the remaining objects
Perform Binary Erosion
The idea is by dilating then eroding you would remove any rough / noisy edges and then you can pass the skeletonized image to the OCR.
There are probably plenty of methods to achieve a similar result. Given that there are entire books devoted to computer vision this answer will hardly do them justice.
The only texts I have are from 1997, but surely there's been more written on the subject since.
Algorithms for Image Processing and Computer Vision - J.R. Parker
Digital Image Processing - Gonzalez / Woods
Offhand, I'd say invert the image (reverse the colors, so that the writing is black on white) and increase the contrast a bit. You can try modifying the brightness to get the erased chalk fogginess to disappear into the background.
In Photoshop, the Levels dialog may be your most useful image adjustment. Mimicking this in code is another subject, entirely.
The basis of Levels is that you adjust the max, min and midpoints of the brightness levels. Usually shown on a histogram, you adjust the points such that you obtain the desired amount of contrast, but also move the midpoint such that text in the image is the most well-defined; critical for OCR applications. By moving the midpoint you can "eliminate" the grayscale fuzz that ordinarily surrounds handwriting by causing it to disappear into the light (or dark) areas of the image.
Also you might try converting the image to 1-bit after such an adjustment, forcing everything to black or white. Sometimes this speeds up the OCR process. But be careful, it also will discard detail.
Have you tried edge detection techniques such as Roberts Cross and Sobel operator to filter noise out of the image? Without seeing the quality of the image, can't say how effective that'd be.
Not sure how constrained you are in the choice of OCR solution, but the ABBYY OCR engine (and a web API based on it, http://www.wisetrend.com/wisetrend_ocr_cloud.shtml ) includes automatic image cleanup / texture removal options.
There are commercial solutions but cleaning up board images appears to be an open problem. Add OCR to an unsolved problem, and you get... an unsolved problem.

Photoshop blending mode to OpenGL ES without shaders

I need to imitate Photoshop blending modes ("multiply", "screen" etc.) in my OpenGL ES 1.1 code (without shaders).
There are some docs on how to do this with HLSL:
http://www.nathanm.com/photoshop-blending-math/ (archive)
http://mouaif.wordpress.com/2009/01/05/photoshop-math-with-glsl-shaders/
I need at least working Screen mode.
Are there any implementations on fixed pipeline I may look at?
Most photoshop blend-modes are based upon the Porter-Duff blendmodes.
These requires that all your images (textures, renderbuffer) are in premultiplied color-space. This is usually done by multiplying all pixel-values with the alpha-value before storing them in a texture. E.g. a full transparent pixel will look like black in non-premultiplied color space. If you're unfamiliar with this color-space spend an hour or two reading about it on the web. It's a neat and good concept and required for photoshop-like compositions.
Anyway - once you have your images in that format you can enable SCREEN using:
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR)
The full MULTIPLY mode is not possible with the OpenGL|ES pipeline. If you only work with full opaque pixels you can fake it using:
glBlendFunc(GL_ZERO, GL_SRC_COLOR)
The results for transparent pixels either in your texture and your framebuffer will be wrong though.
you should try this:
glBlendFunc(GL_DST_COLOR, GL_ONE_MINUS_SRC_ALPHA)
This looks like multiplying to me on the iPhone / OpenGL ES
Your best place to start is to pick up a copy of the Red Book and read through the chapters on on materials and blending modes. It has a very comprehensive and clear explanation of how the 'classic' OpenGL blending functions work.
I have found that using this:
glDepthFun( GL_LEQUAL);
was all need to get a screen effect, at least it worked well on my project.
I am not sure why this works, but if someone knows please share.

Resources