Computer Vision News - June 2016

Let’s examine the code line by line: (line 1) read the image, then (line 2) we set the desired number of pixels in the output (line 3) and the ppi (point per inch), then (line 4) we resize the image according to our preferences - this function uses bicubic interpolation for “generating” the new pixels, and lastly (line 5) we write the new high-resolution image to a new file. 1. image = imread('input.jpg'); 2. toSize = [ 750 2300 ] 3. ppi = 1; 4. imr = imresize(im, toSize * dpi); 5. imwrite(imr, 'output.tif' , 'Resolution', ppi); You are probably wondering : why only 1 PPI ? Well, you have to remember that image resolution has nothing to do with the way images are shown on your screen. Digital image, on its own, has no inherent resolution at all. It's just pixels. Pixels from left to right and from top to bottom. The width and height of an image, in pixels, are known as pixel dimensions, and that's all your screen device cares about. Here are the results. Doesn’t that look way better? Computer Vision News Trick 21 As a side note, we could use the same code for preparing an image with a predefined resolution for printing. For example, we could set the toSize variable in line 2 to toSize = [2.5 7.6] and the ppi in line 3 to 300. The result is an image with the same number of pixels and a size of 2.5 by 7.6 inches with 300 PPI (or DPI - dot per inch). The outcome will be exactly the same image, since [2.5 7.6] * 300 = [ 750 2300 ] (pixels dimension and resolution - it's simple arithmetic).

RkJQdWJsaXNoZXIy NTc3NzU=