Steve on Image Processing

Help! My publisher wants a 300 dpi TIFF 35

Posted by Steve Eddins,

MATLAB user Paul contacted me recently to ask how to convert 150dpi JPEGs to 300dpi TIFFs. After I asked for more information, he explained that he was working with a publisher who expected all electronically submitted images to be 4 inches by 6 inches at 300dpi.

There is often a conceptual disconnect between engineers and scientists doing image processing and printers or publishers. Publishers often seem to think that every image must have a physical size measured in inches, whereas MATLAB users may be working with data whose physical size may be more appropriately measured in kilometers or nanometers. Or the unit may not even be length. Or there may not be a meaningful physical unit at all. Some users don't know what the publisher is even talking about when they say "your image isn't 300dpi."

TIFF files have "resolution" tags in them. These tags specify the number of pixels per unit in the horizontal and vertical directions. The default unit is inches. By default, the MATLAB function imwrite sets these values to 72 pixels per inch, but imwrite has a syntax to specify a different value.

If your publisher specifies image requirements in inches and dpi, first convert that to the number of rows and columns in the image. 4 inches by 6 inches at 300dpi corresponds to 1200 pixels by 1800 pixels. (Caution: terminology confusion between "pixels" and "dots" is rampant and unavoidable. You'll have to rely on the context to figure out which term is meant.) Modify your image to be 1200 by 1800. (Resize it, crop it, compute it differently, etc.) Then save your 1200 by 1800 image to a TIFF file, specifying 300 as the resolution:

imwrite(my_image, 'figure_10_a.tif', 'Resolution', 300);

That should satisfy your publisher.

35 CommentsOldest to Newest

Many publishers also have restrictions on line-widths and font-sizes. I have written a piece of code that automatically can manipulate lines and fonts saving a figure in a varity of formats (eps,png,tif,…) at a specified DPI. Check savefigure in the fileexchange. Me and my mates use it all the time. It can also convert to black and white on the go.

It even attempts to move all axes within a figure to avoid figure boundaries clipping axes labels. This, however, does not work perfectly but can be manually adjusted using margins.

Thanks, it works. To kick it up a notch I summarized your knowledge in a function:
function writeFig300dpi(figNo, fileName)
%make the backgroung white
set(figNo,’color’,’w’);
f=getframe(figNo);
colormap(f.colormap);
imwrite(f.cdata, fileName, ‘Resolution’, 300);

Stephan—The TIFF spec only has three options for resolution unit: inches, centimeters, or none. imwrite does not currently offer a way to change this setting.

if i have an image named 2.jpg of the following parameters : 400*521 at 200 dpi bitdepth 24 into 316*634 at 96 dpi and 24 bitdepth

hi steve
is there any way to write a binary image in arbitrary format(e.g,.ArbitraryHeader, .ArbitraryImage) not in matlab suported format?
sincerely,
Damodar

Wissam—You may find imresize to helpful. We don’t have a way to set the stored DPI value in a JPEG file, just TIFF.

Damodar—If you have a good description of the file format you are interested in, then you can use fopen and fwrite to write out image data in that format.

How can I draw a graph in Matlab with resolution of 1200 dpi and in grayscale ?
I know how to do a graph with 300 dpi and in RGB (which I believe are the default options) but I need a resolution of 1200 dpi and grayscale (and .tiff or .eps format) following the publisher requirements of a scientific journal.

Does anyone can help me please ??

Gabriel—Use print with the -d and -r options. The resulting file will be in RGB format, so you’ll need to read the file back in, convert it to gray scale using rgb2gray, and write it back out using imwrite and the 'Resolution' option.

Hi, I have some scanned images if Tiff format. Is there a way for me to find out what resolution the image was scanned at>
Many thanks,
Michael Yong
35316614433

Michael—Look at the XResolution and YResolution fields in the output of imfinfo. If your scanner stored the information in the TIFF file, it should be in those fields.

Thanks Steve..

Can you help me to determine dot per inch of image I use:
Rec=imfinfo(‘steve.bmp’)
HorzResolution=Rec.HorzResolution;

but it return 7874 insade of 199 that I see in file properity.

thanks

Nawal—I’d appreciate it if you would contact technical support (www.mathworks.com/support) and provide them with a sample file for us to examine.

Steve, I have been trying to order your book “DIP With Matlab” for a few months. Amazon is unable to get it. Are you coming out with a new edition or do you know why I can’t order it? Thanks, Jon

Jon—A transition from one publisher to another has left the book temporarily out of print. I’m very sorry about that! The good news is that the 2nd edition is almost ready.

So, resolution of an image means “dpi” and size of image is the number of pixels say 1200 x 1800. Am I right in this understanding?

Thanks.

I am always confused between the actual size of image (which we get in matlab “size(im)” and resolution) and now I have to measure in “mm” a segmented tube which is in number of pixels from the image…
Thanks.

May—I think there are actually three different notions of “size” floating around in your comments #23 and #24. First, there is the number of rows and columns in the image matrix (1200-by-1800 in your example). Second, there is the size of the image in inches or cm when printed. This is derived from the number of rows and columns and the Resolution and ResolutionUnit tags in the TIFF file. Finally, there is the physical size of the objects in the image. The units could be anything from nm to meters to light years.

Which of these things is called the “actual size” depends on who you ask and what kind of work they do.

I have a .tiff file that is 200 dpi and the publisher needs it to be 300 dpi. It is 1700 x 2200 pixels and I believe 8.5 x 11 inches, but I’m not sure. It won’t let me change the pixels. How do I change it or what software can I use so that it will work for me?

Jan—When you say “It won’t let me change the pixels,” what does “It” refer to?

This blog is about image processing and MATLAB, and the post you commented on talks about how to do the task using MATLAB.

If you don’t have MATLAB and want to use something else, then you should look for an image editing package. There are many such packages, some free and some commercial.

My publisher is wanting images for a new book to be 300 dpi. Only 5 of the 19 images are 300, the rest are either 96 or 150. HOW DO I ENLARGE THE DPI?

I’m on a hard deadline, so any respose would be helpful!!!

Hi, I am importing a geotiff image using imread. I have the .tfw file which gives me the reference info.
I then perform some processing on the image and then which to wish to export the image as a geotiff.
The problem I am facing is that I am not sure what to put into the resolution parameters.
The reference data is the same, so I can reuse the tfw file and rename it accordingly.
What do I do with the the XResolution and YResolution parameters. I thought they should be the pixels per degree, but I cannot change the ResolutionUnit.

Can you provide any help on how to create a geotiff image with the proper referencing and resolution?

Kumaran—GeoTIFF referencing information is stored in a TIFF image using private tags, not using the XResolution and YResolution tags. I don’t know exactly how to do what you are asking. However, since you say the referencing info doesn’t change, you might be able to use the Tiff class (a R2009b) feature to copy the GeoTIFF tag info into your output TIFF file.

Hi all,
I have been struggling myself with this problem. Thanks for all the tips!
I just wanted to add: if you prefer to do it manually (as opposed to command line), once you plot a figure in MATLAB, you may simply click ‘File>Export Setup’. Then you can choose the Resolution and the size at the same time.
I thought this was convenient and simple enough to be mentioned here.

Wow, submission just became less time-consuming :)

These postings are the author's and don't necessarily represent the opinions of MathWorks.