Minimalistic way to read TIFF image format pixels - tiff

We are participating at the RoboCup 2015 from the German Aerospace Center in October. Before the torunament we will get a 30x30 pixel sized TIFF image, representing a low-pixel heigtmap. My task is to write a fast and lightweight, dependency free code that reads this TIFF image an does some algorythmic stuff on it.
I googled about the TIFF image format and it seems there are some powerfull libraries, but is there a simple way of reading just the color values of the file?
I remember a format, don't know which, where I just skipped the first 30 bytes and then could read the color values in RGB. Do you have any code that could do that or an idea/explanation how I could acchieve that?
As I said, I do not need filename, imagesize data etc. I actually don't even know why they have choosen the TIFF image-format since its just a normal heightmap in greyscale, but however.
Every help is very appreciated.

Related

Producing many different hashes of a jpg file with minimal change to picture

My goal is to write a program (e.g. in Python or C++) which takes as input a JPG file (e.g. tux.jpg) and make tiny changes to it, such that it outputs many different images (maybe a thousand images or even more), but in a way that all these images, while having different hash, look almost the same visually, i.e. the changes should have the least impact to the original image as possible.
I first though to play around with the jpg header but that might not be enough to make the many thousands of different pictures I want.
As a naive way, I thought to flip a random bit in the file, but that bit can possibly result in a less than desirable result, which can be seen especially in small pictures (e.g. a dark pixel in the white space in the tux picture). Ideally, I would like to change a random pixel with a "neighboring" color, such that the two resulting pictures have almost no visual difference.
For this purpose, I read the JPG codec example but I find it very confusing and hard to understand. Can someone help me what my program should look for as it parses the file in binary format and how to change a random pixel with a "neighboring" color?
You can change the comment part of the file by playing with the file header. A simple way to do that is to use a ready made open source program that allows you to put the comment of your choice, example HLLO repeated 8 times. That should give you 256 bits to play with. You can then determine the place where the HLLO pattern is located in the file using a hex editor. You then load the data in memory and start changing these 32 bytes and calculate the hash each time to get a collision (a hash that matches)
By the time you find a collision, the universe will have ended.
Although in theory doable, it's practically impossible to crack SHA256 in a reasonable amount of time, standard encryption protocols would be over and hackers would be enjoying their time.

Is there any loss of information in converting jpg files to png?

I am working on an image dataset using deep learning for segmentation. The training images and masks are in jpg format. I would like to know whether there is any loss of information in converting jpg to png? I searched a bit, but couldn't get any relevant information. I am trying out whether using png images improves segmentation accuracy. Any help is appreciated.
PNG uses a lossless compression per default.
However, the PNG standard supports many different bit depths, color spaces and nifty features that can result in information loss. For example if you use a standard JPEG file with 24bit color and convert it to a PNG with 8bit color, you will lose image information.
When using default settings in libraries such as OpenCV or PIL, the conversion will be lossless though.

How to convert jpg or png images to dicom format in Lazarus?

The question is clear, How to convert jpg or png images to dicom format in Lazarus?
There are several commercial libraies which support DICOM file format. Or you can build your own.
Basically DICOM is a container. Images withing this containers can have a lot of different formats, including simple RGB raw image (that is 3 bytes per pixel, one for each primary color). The container also contains metadata. This can mostly be fixed. The only exception is image size.
There are plenty of DICOM resources on the web. Google is your friend.

How to get a High quality portable render of an arbitrary sized html document?

I'm trying to design a poster using HTML, currently CSS allows me to get a huge canvas (90cmx200cm), but I can't get a document to send for printing.
Chromium does not allow using custom paper size and Firefox let me use the required size (on non-standard inches) but fails miserably to render a high quality PDF (Even 20px text that looks good when browsing w/o zoom).
I was thinking that I should be able to get a lower level interaction with the renderer to get this done.
The output format is irrelevant as long as it's portable enough.
Is there a way to achieve this?
There are a few things you need to know. Firstly print quality is related to dots-per-inch. Best software and printer in the world isn't going to make a 100 x 100 pixels photo print quality.
http://www.vsellis.com/understanding-dpi-resolution-and-print-vs-web-images/
Images on web pages are rasterized images, and typically quite low resolution (compressed formats such as JPEG and PNG to reduce bandwidth use). You might try using high-resolution images and scaling them with CSS (I have not idea how this will print though).
Make sure all of your text is actually text (don't use images).
To improve quality ensure images are high resolution. If possible you could explore using SVG, which is a loss-less format for diagrams and line drawings. I believe this should be preserved if you print to PDF. There are also third party libraries that convert SVG to PDF.

Optimal configuration for Tessnet -- is image format conversion good enough?

I need to do OCR on a group of images. I have been using Tessnet and it works pretty well. The problem is that it seems to have problems with some images, so I thought that it might work better if I modify the images' brightness, contrast, etc. Also, the images are in .jpg format, but I read that .tiff is optimal.
What can I do? Should I just convert the JPEGs to TIFFs?
There's no point in converting the jpeg images to a lossless format like tiff, you will convert the artifacts as well. You could try and apply a sharpness kernel on the image before you try to do ocr on it.
Look at this page for more information.