Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How do I make the image not fit the window?

I want a square window, but I don't want the image to fit the window, I want it to either scale to height or scale to width. Example:

image = cv.imread("image.png")

width = 300
height = 70
dim = (width, height)

resized = cv.resize(image, dim, interpolation =cv.INTER_AREA)

cv.namedWindow("image", cv.WINDOW_NORMAL) 
cv.resizeWindow("image", 300, 300)
cv.moveWindow("image", 50, 50)

cv.imshow("image", resized)

I want a 300x70 image centered inside a 300x300 window, but every time I try it, the image gets stretched kind of like this:

image description

vs

image description

How do I make the image not fit the window?

I want a square window, but I don't want the image to fit the window, I want it to either scale to height or scale to width. Example:

image = cv.imread("image.png")

width = 300
height = 70
dim = (width, height)

resized = cv.resize(image, dim, interpolation =cv.INTER_AREA)

cv.namedWindow("image", cv.WINDOW_NORMAL) 
cv.resizeWindow("image", 300, 300)
cv.moveWindow("image", 50, 50)

cv.imshow("image", resized)

I want a 300x70 image centered inside a 300x300 window, but every time I try it, the image gets stretched kind of like this:

image descriptionimage description

vs

image descriptionimage description

How do I make the image not fit the window?

I want a square window, but I don't want the image to fit the window, I want it to either scale to height or scale to width. Example:

image = cv.imread("image.png")

width = 300
height = 70
dim = (width, height)

resized = cv.resize(image, dim, interpolation =cv.INTER_AREA)

cv.namedWindow("image", cv.WINDOW_NORMAL) 
cv.resizeWindow("image", 300, 300)
cv.moveWindow("image", 50, 50)

cv.imshow("image", resized)

I want a 300x70 image centered inside a 300x300 window, but every time I try it, the image gets stretched kind of like this:

image description

vs

image description

Also, is there a way of having the image size independent of the window size? So I can stretch the window manually with the mouse without changing image size.

How do I make the image not fit the window?

I want a square window, but I don't want the image to fit the window, I want it to either scale to height or scale to width. Example:

image = cv.imread("image.png")

width = 300
height = 70
dim = (width, height)

resized = cv.resize(image, dim, interpolation =cv.INTER_AREA)

cv.namedWindow("image", cv.WINDOW_NORMAL) 
cv.resizeWindow("image", 300, 300)
cv.moveWindow("image", 50, 50)

cv.imshow("image", resized)

I want a 300x70 image centered inside a 300x300 window, but every time I try it, the image gets stretched kind of like this:

image description

vs

image description

Also, is there a way of having the image size independent of the window size? So I can stretch the window manually later with the mouse without changing image size.

How do I make the image not fit the window?

I want a square window, but I don't want the image to fit the window, I want it to either scale to height or scale to width. Example:

image = cv.imread("image.png")

width = 300
height = 70
dim = (width, height)

resized = cv.resize(image, dim, interpolation =cv.INTER_AREA)

cv.namedWindow("image", cv.WINDOW_NORMAL) 
cv.resizeWindow("image", 300, 300)
cv.moveWindow("image", 50, 50)

cv.imshow("image", resized)

I want a 300x70 image centered inside a 300x300 window, but every time I try it, the image gets stretched kind of like this:

image description

vs

image description

Also, is there a way of having a fixed image size? So even if I change the image window size independent with my mouse later the size doesn't change, but stay the same on the center of the window size? So I can stretch the window manually later with the mouse without changing image size.window.

How do I make the image not fit the window?

I want a square window, but I don't want the image to fit the window, I want it to either scale to height or scale to width. Example:

image = cv.imread("image.png")

width = 300
height = 70
dim = (width, height)

resized = cv.resize(image, dim, interpolation =cv.INTER_AREA)

cv.namedWindow("image", cv.WINDOW_NORMAL) 
cv.resizeWindow("image", 300, 300)
cv.moveWindow("image", 50, 50)

cv.imshow("image", resized)

I want a 300x70 image centered inside a 300x300 window, but every time I try it, the image gets stretched kind of like this:

image description

vs

image description

Also, is there a way of having a fixed image size? So even if I change the window size with my mouse later the size doesn't change, but stay the same on the center of the window.window (like this)

How do I make the image not fit the window?

I want a square window, but I don't want the image to fit the window, I want it to either scale to height or scale to width. Example:

image = cv.imread("image.png")

width = 300
height = 70
dim = (width, height)

resized = cv.resize(image, dim, interpolation =cv.INTER_AREA)

cv.namedWindow("image", cv.WINDOW_NORMAL) 
cv.resizeWindow("image", 300, 300)
cv.moveWindow("image", 50, 50)

cv.imshow("image", resized)

I want a 300x70 image centered inside a 300x300 window, but every time I try it, the image gets stretched kind of like this:

image description

vs

image description

Also, is there a way of having a fixed image size? So even if I change the window size with my mouse later the size doesn't change, but stay the same on the center of the window (like this)

How do I make the image not fit the window?

I want a square window, but I don't want the image to fit the window, I want it to either scale to height or scale to width. Example:

image = cv.imread("image.png")

width = 300
height = 70
dim = (width, height)

resized = cv.resize(image, dim, interpolation =cv.INTER_AREA)

cv.namedWindow("image", cv.WINDOW_NORMAL) 
cv.resizeWindow("image", 300, 300)
cv.moveWindow("image", 50, 50)

cv.imshow("image", resized)

I want a 300x70 image centered inside a 300x300 window, but every time I try it, the image gets stretched kind of like this:

image description

vs

image description

Also, is there a way of having a fixed image size? So even if I change the window size with my mouse later the size doesn't change, but stay the same on the center of the window (like this)window, example:

image description