Reputation: 652
I am taking an image as input, and parsing it pixel by pixel, and save the pixel coordinates that matches a specified color. Then i am asking the user to provide the max height and width of image in mm.
So, now while scaling the image, from converting pixel into mm, using this formula
x = (width*25.4)/(dpi);
I want an output which can scale according to the user given height and width. So, even if the image is too large or small, it should scale according to user's height and width. Can anyone have any idea about it?
Upvotes: 0
Views: 1706
Reputation: 26
As i understand that you want to know the new height and width of the image according to the user input in mm, if i understand right first thing you need to know how many pixels represent one mm in your image , that may be a knowledge you knew from your environment settings or you may achieve that by knowing a specific object in the image that you already knew its dimension in the real world in mm and then calculate its dimension in your image as px so as example : if there is a box in the image its height in real world is 200mm and in image is 20 px so yo now know that 20px = 200 mm , then 1 mm is equal to 20/200 px = 0.1px then when the user enter a value in mm say 15 mm you now know that equal to 15*0.1 px.
note that the numbers i showed is just for explanation it may not make sense
Upvotes: 1