mlampros / OpenImageR

Image processing Toolkit in R
https://mlampros.github.io/OpenImageR/
57 stars 10 forks source link

resizeImage mixes up width and height #15

Closed stuart-morrison closed 4 years ago

stuart-morrison commented 4 years ago

There is an issue with the resizeImage function where:

An example below.

library(OpenImageR)

# Download a photo of a nice water bottle
url <- "https://www.rei.com/media/269dbba5-dae6-4f57-9053-8a2a7d89925a?size=784x588"
download.file(url,'nalgene.jpg', mode = 'wb')

# Read in image with OpenImageR
image <- readImage("nalgene.jpg")

# Display the dimensions
# Image is 588 high, 325 wide
dim(image)
## [1] 588 325   3

# Resize the image by a factor of 0.5
resized_image <- resizeImage(image = image, 
                             width = dim(image)[2] * 0.5,
                             height = dim(image)[1] * 0.5)

# Display the dimensions of the resized image
# Image is now wider than it is high
dim(resized_image)
## [1] 162 294   3

# Plot the mutated image
plot(as.raster(resized_image))
mlampros commented 4 years ago

hi @stuart-morrison,

in the documentation of the OpenImageR package for the resizeImage function it is specified,


width,  a number specifying the new width of the image. Corresponds to the image-rows.
height, a number specifying the new height of the image. Corresponds to the image-columns.

To clarify and avoid any confusion, the width corresponds to the image-rows and the height to the image-columns.

I get your point but the terminology can not be changed. On the other hand if it's required for your task / project, then feel free to fork or download this repository and make your own adjustments.

stale[bot] commented 4 years ago

This is Robo-lampros because the Human-lampros is lazy. This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 7 days if no further activity occurs. Feel free to re-open a closed issue and the Human-lampros will respond.