In R, the png function allows length and width input arguments in pixel number rather than inches. How do I relate this value to PPI if I can't set length and width in inches? For example, the default png has 480x480 = 230400 pixels. How many square inches is the default image size, so that I can calculate ppi? I need to generate ppi=300 for publications, but to do this, I need to know how many square inches I am filling with X number of pixels.
Related
I always resized images in CorelDraw from 1219,20 x 914,40mm to 78.36x51.00 to make photo boards. But now it turns out I have a lot of images in different folders and I needed to create an auto-lop to do this for me. If I were to do this in Corel like I used to do, it would take a lot of time.
I have used the the resize function from Magick package, but didn't have obtain sucess.
resize(Image, "78.36x51.00!")
Error in resize("78,36x51,00!") :
Not compatible with requested type: [type=character; target=integer].
So I also tried the image_scale function, in this case the dimensions changed, but the size and resolution of the image was much smaller than expected.
image_scale(Image, "78.36x51.00!")
Demonstration with the generated image after the resize (photo) and the expected size (white square)
Documentation indicates that magick's scaling functions are based on pixels. Scaling based on X and Y dimensions expressed as pixels is shown below.
I'm not sure if this directly addresses the issue because the units in the question seem to change and dots per inch (dpi) is not defined. 1219,20 x 914,40 is in mm, but the units for 78.36 x 51.00 are undefined. The first pair of numbers has an aspect ratio of 1.3 while the second is 1.5.
Scaling by X or Y in pixels will retain the original aspect ratio. Getting the right size involves knowing the desired dpi.
install.packages("magic")
library(magick)
Image <- image_read("https://i.stack.imgur.com/42fvN.png")
print(Image)
# Increase 300 in X dimension
Image_300x <- image_scale(Image, "300")
print(Image_300x)
# Increase 300 in y
Image_300y <- image_scale(Image, "x300")
print(Image_300y)
It is my understanding that h264 motion vectors represent an area of 4x4 or 16x16 pixels. What happens if an image height or width is not divisible by 4? Is this even allowed?
The height and width must be divisible by 16 for progressive footage.
Rec. ITU-T H.264 (04/2017) page 21
The width and height of the luma sample arrays are each an integer multiple of 16. In coded video sequences using 4:2:0
chroma sampling, the width and height of chroma sample arrays are each an integer multiple of 8. In coded video sequences
using 4:2:2 sampling, the width of the chroma sample arrays is an integer multiple of 8 and the height is an integer multiple
of 16. The height of a luma array that is coded as two separate fields or in macroblock-adaptive frame-field coding (see
below) is an integer multiple of 32
I'm writing a GNU Makefile to do some processing on images.
One task is to scale the image (.ppm format) by a SIZE parameter using the pnmscale command. The image should be scaled by the longer side without loosing the ratio and should be saved under .scaled .
I've read the man page of pnmscale but couldn't seem to find the right option.
I've tried the following:
pnmscale -pixels 100 example.ppm > example.scaled
When example.ppm has the size 200 x 100 pixels and I run the pnmscale command with the size of 100 pixels, example.scaled should have the size of 100 x 50 pixels. With my solution the image gets very small.
As the manpage of pnmscale states, the option pixels
specifies a maximum total number of output pixels. pnmscale scales the image down to that number of pixels. If the input image is already no more than that many pixels, pnmscale just copies it as output; pnmscale does not scale up with -pixels.
In other words, by specifying -pixels 100, you're actually scaling down your image to a maximum number of 100 pixels. What you're trying to achieve is to scale down your input image to a size of 100 x 50 pixels = 5000 pixels.
Looking again at the manpage of pnmscale yields the following:
pnmscale [{-xsize=cols | -width=cols | -xscale=factor}] [{-ysize=rows | -height=rows | -yscale=factor}] [pnmfile]
[...]
If you specify one dimension as a pixel size and don't specify the other dimension, pnmscale scales the unspecified dimension to preserve the aspect ratio.
In your case, using
pnmscale -xsize 100 example.ppm > example.scaled
should shrink your input image to a width of 100 pixels.
I want to increase pixel density per unit area on every zoom operation in 'QPixmap'.
To increasing pixel density I create pixmap on every zoom according to the rectangle get from sceneboundingrect() but I think it does not increase the pixel density
The QPixmap is a raster image, that means a finite amount of pixels, making it bigger will not make it clearer (as it does on CSI).
You will need a considerably bigger / larger resolution image to begin with, then you will downsample it when you render it "un-zoomed" and the more you zoom in the closer you render it to its original size.
It sounds simple but how is the fontsize, which can be set with setPointSize defined in Qt4? A point is 1/72 inch but if I compare to
glyph metrics from FreeType
Is it the max_advance_height, the advance between two lines or the distance between the highest and lowest point (the maximum ascender - descender)?
If I create a QLabel and setPointSize to 75 I get the following result:
My screen has 96x96 dpi which should result in 75/72*96 = 100 pixels. But measured the B, for example is 70 pixels in height.