Why do images have a ppi value? - image

When a file describes an image it should work somewhat like this: color value of the pixel in the upper left corner = whatever. next: the color of the second pixel = whatever. and so on. so that in the end I have a description of say 1000x1000 pixels. now how can this image description have a ppi value? if I have a screen that has 1000x1000 pixels and is 22" in size, the dpi will be different from a screen with 1000x1000 pixels and 24". so the dpi depends on the screen that I use to view the image, it's not a property of the image. but images do have a ppi value, I just don't understand the logic behind that?

Related

What is the image editor's resolution tool for?

I have an image that is 320 x 482 pixels size and 72 PPI. I can change the image resolution with GIMP for example, but why would I use it if the images suits its pixel size for each display pixel size? I mean, an image changes its size in inches depending on the display density, right? So why would I want to change the PPI of an image, that doesn't make sense to me, although I understand that GIMP and any other image editors wouldn't put this feature for nothing.
PS: I tried to change the resolution of some images and compare it with the original image and apparently nothing happened but the size in inch of the image.
An image's DPI is defined by the capturing hardware and will impact it's size when printed out.
Changing the resolution won't change the number of pixels in the image.

Calculate DPI of image

I have an image on a canvas. That image will be resized by user.After that, the canvas content will pe printed at a specific dimension.
I want to calculate the DPI of the resized image, so i can tell the user if he resized to much and the printed quality will be affected.
Does someone know a formula for this?
DPI means dots per inch.
Divide the pixel size of the image with its physical dimensions in inches.

How to convert gray scale image which assigned threshhold value in some pixel of original RGB image to RGB?

I have original RGB image.
then, I convert it to gray scale.
then, I assign new threhold value into some pixel.
then, I need to convert the gray scale image from step#3 to RGB image.
I am trying on the step#4. Could you help to advise?
Check out rgb2hsv and hsv2rgb in matlab. Then threshold on the value matrix. This makes more sense to me.
Another possibility is to convert to grey scale but keep the original colour image. Then create a mask by thresholding the grey scale image and use that mask to discard the pixels above/below your threshold on the colour matrix.

Cropping an image with a focus area (face) using ImageMagick

I'm struggling to find the right approach to resize and crop and image, with a focus area. In my case the focus area is a face detected in the image, and I need to make sure that this area is visible in the cropped version.
I have focus area given by eg. face_height, face_width, face_center_x and face_center_y. These values are percentages of dimensions of the original image.
What I want to do, is getting a eg. 60x60 thumbnail. The normal approach would be to resize so either height or width of the image is equal 60px and then crop a 60x60 from center, like this:
mogrify -resize 60x -gravity 'Center' -crop 60x60 image.jpg
What approach can be taken focus my crop around a given area instead?
I'm thinking of a solution that includes several paths:
If the face area is bigger than the wanted thumbnail, resize the image just enough to make the whole face visible in 60x60 pixels, then crop
If the face area is smaller than the wanted thumbnail, then crop "expand" my face area until my wanted thumb can fit inside the area. Then crop. I guess I need to make sure that this doesn't exceed the bounds of the original image.
Is there a smarter approach? Can you try make some example code?
Thanks!
I'd first do the arithmetic in script or program, then feed exact coordinates to ImageMagick.
The arithmetic steps:
It'll be easier to operate with exact pixel values than percentages, so convert face_height, face_width, face_center_x and face_center_y to pixel values.
You'll want rectangular thumbnail, so pick the longest side and operate with that:
longest_side = max(face_height, face_width)
Now you can calculate top left point for your crop:
crop_x = face_center_x - longest_side / 2
crop_y = face_center_y - longest_side / 2
If any of the four crop corners fall outside your picture dimensions, adjust for that:
crop_x and crop_y should both be >= 0
crop_x + longest_side should be less than image width
crop_y + longest_side should be less than image height
Having calculated these, ImageMagick call gets quite straightforward:
mogrify -crop {longest_side}x{longest_side}+{crop_x}+{crop_y} -resize 60x60 image.jpg

is there any difference between grey scale image and binary image?

is there any difference between grey scale image and binary image?
Yes, the one is grayscale, e.g. gray scales from 0.255, the binary imange is binary, that means black(0) or white(1).
EDIT: Convert grayscale to binary. Directly converting color images (like RGB) to binary is not that easy, because you have to handle every color channel within the image seperatly.
Converting to binary is done using a ceratin threshold. E.g. you can say, all pixels with gray > 125 will become white, the others black.
There are several thresholding algorithm out there, but maybe the most common is Otsu. You can find it here Thresholding by Otsu
Yes, but I'm not sure what this has to do with C++ or programming. A binary image could be an image where pixels are only either red or blue.
Binary Image: http://en.wikipedia.org/wiki/Binary_image
Grayscale Image: http://en.wikipedia.org/wiki/Grayscale
A binary image has only two values for each pixel, 0 and 1 corresponding to black and white (or vice versa). A gray scale image has a certain number (probably 8) bits of information per pixel, hence, 256 possible grey values.
Of course, a grey scale image has a binary representation, but the smallest size of information is not a bit, so we don't call it a binary image.
edit Assuming you want to convert in Matlab, use im2bw. If you're not using Matlab, the idea of binarization is explained on that page as well. It's not difficult to port, it boils down to comparing every pixel to a threshold value.
Black and White image contains only two levels.
Gray image represent by black and white shades or combination of levels for e.g.
8 bit gray image means total 2^8 levels form black to white 0 = black and 255 is White.
Yes,
A binary image is one that consists of pixels that can have one of exactly two colors, usually black and white. It is also called bi-level or two-level.
A gray scale image is a kind of black and white or gray monochrome are composed exclusively of shades of gray.
Yes
Binary Image
A binary image is a black and white image where each pixel value is either 0 or 1. The value 0 represents background or black and the value 1 represents foreground or white.
Grayscale Image
A grayscale image is a black and white image with various shades of gray. The pixel value of a grayscale image is represented as an 8 bit signed integer. i.e values between 0 and 255. The pixel value of the grayscale image represents the brightness of the pixel. The value 0 is black, the value 255 is white, and the values in between makeup different shades of gray.

Resources