Why is the pure Cyan image in this PDF not displayed as pure Cyan? - pdf

Can anyone tell why the image in this pdf does not display as 100% Cyan?
clrtestc - NOPREBLEND32.PDF
Warning: I probably know just enough about pdf and colour to be dangerous!
I'm pretty sure each colour plane of the image is in a separate image. Here's a blended version if that helps.
I know the ColorSpace is DeviceCMYK
I'm pretty sure there is only 100% Cyan in the image, at least there was when it went into the PDF converter.
What went in:
CMYK: 100,0,0,0
RGB: 0,255,255
What I measure coming out:
CMYK: 100,27,0,6
RGB: 0,173,238
I'm foxed! Is there some filter affecting the rendering of the PDF?
There's also Magenta, Yellow and Black versions if they help.
Any help much appreciated.

The PDF file is extraordinarily complicated, it has numerous Forms, some of them nested, most of which are empty. However there only appears to be one image, which is defined in an Indexed CMYK space. So as far as I can see, this is indeed a 100% cyan image.
The extended graphics state does use the Multiply Blend mode, and there is no group and no page group specified, so the colour space used for the blending will depend on the colour model of the output device. If that's a monitor, then it's entirely possible that the resulting output will be RGB.
That's because your CMYK image needs to be converted to RGB in order to be blended using that colour space.
Incidentally, the image is in an Indexed colour space. In your image all the image samples have the same value, that value is then consulted in a lookup table, and that table returns the CMYK components. So no, there is not one image per colour plane, or at least, not in this file.
To be honest, you're going to have to explain better how you are evaluating the content of the PDF file. As far as I can see the image is 100% cyan, and when rendered to a CMYK device, it will remain 100% cyan. If you render to an RGB device, it will be converted to RGB. A poor quality PDF consumer might decide to convert to RGB in the absence of a defined colour space for the blending operation.
Since the blending mode doesn't actually do anything (there's no defined alpha, SMask or any other transparency in the file) you could remove that and see if it sorts out your problem.
Edit
Your screen will be an RGB device, so no matter what the CMYK values in the PDF file are, there won't be any CMYK in the screenshot. The PDF rendering engine will have to convert the CMYK to RGB.
So the PDF rendering engine performs an opaque CMYK->RGB conversion. Then you take a picture of that RGB screen. You load that into an image editing application, and ask it what the RGB values are and presumably what it thinks are the CMYK equivalents.
If the CMYK->RGB calculation that the PDF viewer performs is not the inverse of the calculation that the RGB->CMYK image application performs, then you won't be getting the right values!
There's no way to predict what the RGB intermediate values 'should' be, because there is no 'right' answer here. Fundamentally this isn't a reliable technique for evaluating the colour.
It's hard to make any kind of recommendation without knowing what you are trying to achieve (and possibly why), and what tools you are prepared to use. I believe Acrobat Pro would allow you to look at the colour values directly for example. Or you could use something like Ghostscript to create a CMYK TIFF file, then open that in an image application which supports CMYK (like Photoshop) and look at the values there.
But rendering to the screen, taking a screenshot and trying to figure out what the CMYK values might or might not have been is not really going to work.

Related

How can I get a CMYK colour from a pdf?

I need to detect the CMYK colour of some text in a pdf. Just like you can with Acrobat's Print Production/Output Preview feature, but via a vb.net program.
I've used Ghostcript's inkcov command in the past to do something similar and get the CMYK value of ink coverage in a specified area of a pdf, but I can't seem to find a way to list the individual different CMYK values this way.
I've tried using SpirePDF to get the co-ordinates of the text and then producing a bitmap from the area, and then looping through the pixels to get the RGB values, but I can't get a CMYK value this way. Trying to convert the RGB to CMYK doesn't produce a close enough match to the original colour, so I think I have to stick with working directly on the pdf.
Using Ghostcript to isolate the area I'm interested in, I can probably produce a pdf with just some text in the colour I want to find, plus the background colour, but how do I get the text colour from that stage?
Or is there an easier approach?

Vulkan swapchain format UNORM vs SRGB?

In a Vulkan program, fragment shaders generally output single-precision floating-point colors in the range 0.0 to 1.0 to each red/blue/green channel, and these are then written to (blended into) the swapchain image that is then presented to screen. The floating point values are encoded into bits according to the format of the swapchain image (specified when the swapchain is created).
When I change my swapchain format from VK_FORMAT_B8G8R8A8_UNORM to VK_FORMAT_B8G8R8A8_SRGB I observe that the overall brightness of the frames is greatly increased, and also there are some minor color shifts.
My understanding of the SRGB format was that it was a lot like the UNORM format just having a different mapping of floating point values to 8-bit integers, such that it had higher color resolution in some areas and less in others, but the actually meaning of the "pre-encoded" RGB floating-point values remained unchanged.
So I'm a little suprised about the brightness increase. Is my understanding of SRGB encoding wrong? and/or is such a brightness increase is expected vs UNORM?
or maybe I have a bug and a brightness increase is not expected?
Update:
I've observed that if I use SRGB swapchain images and also load my images/textures in VK_FORMAT_B8G8R8A8_SRGB format rather than VK_FORMAT_B8G8R8A8_UNORM then the extra brightness goes away. It looks the same as if I use VK_FORMAT_B8G8R8A8_UNORM swapchain images and load my images/textures in VK_FORMAT_B8G8R8A8_UNORM format.
Also, if I put the swapchain image into VK_FORMAT_B8G8R8A8_UNORM format and then load the images/textures with VK_FORMAT_B8G8R8A8_SRGB, the frames look extra dark / almost black.
Some clarity about what is going on would be helpful.
This is a colorspace and display issue.
Fragment shaders are assumed to be writing values in a linear RGB colorspace. As such, if you are rendering to an image that has a linear RGB colorspace (UNORM), the values your FS produces are interpreted directly. When you render to an image which has an sRGB colorspace, you are writing values from one space (linear) into another space (sRGB). As such, these values are automatically converted into the sRGB colorspace. It's no different from transforming a position from model space to world space or whatever.
What is different is the fact that you've been looking at your scene incorrectly. See, odds are very good that your swapchain's VkSurfaceFormat::colorSpace value is VK_COLOR_SPACE_SRGB_NONLINEAR_KHR.
VkSurfaceFormat::colorspace tells you how the display engine will interpret the pixel data in swapchain images you present. This is not a setting you provide; this is the display engine telling you something about how it is going to interpret the values you send it.
I say "odds are very good" that it is sRGB because, outside of extensions, this is the only possible value. You are rendering to an sRGB display device whether you like it or not.
So if you write to a UNORM image, the display device will read the actual bits of data and interpret them as if they are in the sRGB colorspace. This operation only makes sense if the data your fragment shader wrote itself is in the sRGB colorspace.
However, that's generally not how FS's generate data. The lighting computations you compute only make sense on color values in a linear RGB colorspace. So unless you wrote your FS to deliberately do sRGB conversion after computing the final color value, odds are good that all of your results have been in a linear RGB colorspace. And that's what you've been writing to your framebuffer.
And then the display engine mangles it.
By using an sRGB image as your destination, you force a colorspace conversion from linear RGB to sRGB, which will then be interpreted by the display engine as sRGB values. This means that your lighting equations are finally producing the correct results.
Failure to do gamma-correct rendering properly (including the source texture images which are almost certainly also in the sRGB colorspace, as this is the default colorspace for most image editors. The exceptions would be for things like gloss-maps, normal maps, or other images that aren't storing "colors".) leads to cases where linear light attention appears more correct than quadratic attenuation, even though quadratic is how reality works.
This is gamma correction.
Using a swapchain with VK_FORMAT_B8G8R8A8_SRGB leverages the ability to to apply gamma correction as the final step in your render pipeline. This happens for you automatically behind the scenes.
That is the only place you want gamma correction to happen. Make sure your shaders are not applying gamma correction. You might see it as:
color = pow(color, vec3(1.0/2.2));
If your swapchain does the gamma correction, you do not need todo it in your shaders.
Most images are SRGB (pictures, color textures, etc). Linear images are for specific data, like a blue noise texture or heightmap.
Load SRGB images w/ VK_FORMAT_R8G8B8A8_SRGB
Load LINEAR images w/ VK_FORMAT_R8G8B8A8_UNORM
No shader conversion is required if the rules outlined above are followed.

How to cut the png image as per the shape?

I have no experience on any image processing/editing tool. And I am doing a project, which requires me to use different shapes. I could create different shapes using visio. But however not able to get rid of white background behind. I need only shape not squared white background.Tried online out of my ways but not successfull.
Any help will be greatly appreciated.
Thanks,
Ganesh
Absolutely any image file has to be contained within a rectangular frame, this includes png and SVG.
Some image file formats can have what are called alpha channel backgrounds this allows you to see through transparent areas.
What you want to do is remove the white background to expose the alpha channel background in Photoshop (or similar tool) which can then be saved out as transparent.
For example in Photoshop:
If you open this image directly and have no other layers, double click the layer that says background and OK the confirmation box. This turns your flat image into a layered image
Select the magic wand tool and ensure you have a high tolerance set (3)
with the wand selected click the white area to bring up a marquee around your selection (the white background) and hit delete to remove it.
Your image should now have a chequered background which is the transparency showing through.
If you now go to file > save as and select png, your image should now be saved out with an alpha background.
Please note: There are further optimisations to make if this is for web, including file formats and file size but that is beyond the scope of this question but I encourage you to read up on the Gif format and it's restrictions, the difference between 8bit and 24bit pngs and how to use SVG.
You can do it pretty simply at the command-line using ImageMagick which is free and installed on most Linux distros and is available for OSX and Windows.
Basically, you want to make your whites transparent, so you would do
convert shape.png -transparent white result.png
If your whites are a little bit off-white, you could allow for some variation with a little fuzz as follows:
convert shape.png -fuzz 10% -transparent white result.png
I added the checkerboard background just so you can see it on StackOverflow's white background - it is not really there.
By the way, you may like to trim to the smallest bounding rectangle while you are there:
convert shape.png -fuzz 10% -transparent white -trim result.png
By the way, you can also draw your shapes with ImageMagick:
convert -size 150x150 xc: -fill none -stroke "rgb(74,135,203)" -draw 'stroke-width 90 ellipse 0,0 80,80 30,80' arc.png
See Anthony Thyssen's excellent examples here.

What is the highest quality export for Spotfire visualizations?

I have a question regarding high quality exports from spotfire to PDF.
I read on Spotfire support page that to obtain highest quality exports for visualizations you should select vectors (instead of rastar). They still provide better quality than rastar graphics with maximum quality (5 out of 5). However, when I export these images to PDF, the quality is relatively low. Is there a way I can increase the quality? Would it help to select e.g. PPT exports? I think manual screenshots are still better in quality, but more timeconsuming. We are looking for end-user friendly interface.
Furthermore, if your table is longer and you use slider, what is the recommended way of exporting such a graphic?
Thanks a lot.
raster graphics are generally lower quality. jpeg, for example, is a raster format, where each pixel in the image is coded to a specific color; if you resize the image, it becomes blurry or loses detail.
vector format defines points, lines, and shapes that make up an image. when you scale the image up or down, there is no guesswork trying to blend pixels -- instead the points are recalculated to whatever size. for example, fonts are usually vector format, which is what allows them to be scaled up or down to any size.
the quality of the vector image may be low due to the zoom settings on your PDF viewer (although the image can be scaled to any size, your screen still relies on pixels to display it), but it is the most possible detail. if you zoom in you will probably see an increase in quality.
manual screenshots probably look "best" because there is no scaling or resizing involved. you can export to PNG (raster) image format to get the same effect.
you will not see an increase in quality by exporting to Powerpoint. either you will export it as a raster image to a PPT slide (default settings) or you will export it as a vector using the "As Editable Image" checkbox (which allows you to modify the image in PPT).
what is your end goal? Spotfire is best suited for viewing in the Desktop or Web Player applications, otherwise you lose a lot of features like interactivity, (potentially) live date. if you have to make a lot of exports maybe it is easier to simply provide a link to the analysis?
to your final question, Spotfire is not very good at table exports. I have had some luck with increasing the page size (A4 or A5, for example) and using Landscape over Portrait. again, I recommend to view it in the application.

PDF Low-level: Invert colors within coordinates

Is it possible to invert the colors within a box (4 sets of coordinates) on a page from within the page's content object code?
My pages consist of simple B&W JBIG2 images and I wish to make the white black and the black white within a small box to highlight something.
As mkl suggests, you may extract the images and change their bits - this might prove to be a little bit of work however. There might be another useful approach here, specifically useful because it would work regardless of what the underlying objects are.
It is possible in PDF to add a transparent object (for example a rectangle) over all underlying objects. In your case you would create a rectangle that you put on top of the images you already have in the page stream.
If you paint this rectangle in white, set it to transparent and choose "Difference" as the transparency blending mode, the net effect should be that the colors underneath your rectangle are inverted.
From the PDF specification: "Painting with white inverts the backdrop colour; painting with black produces no change."
This may be the quickest and most painless way to accomplish what you are looking for...