Scaling by percentage

Let's start by scaling the image using percentages. Let's say we want to scale the image to be 60% of the original size:

  using Images, ImageView  source_image = load("sample-images/cats-3061372_640.jpg");  scale_percentage = 0.6  new_size = trunc.(Int, size(source_image) .* scale_percentage)  resized_image = imresize(source_image, new_size)  imshow(resized_image);

We have done the following:

  • We have loaded the image using the load function from the Images package
  • We have defined the scaling percentage in the scale_percentage variable
  • We have calculated the new_size by first multiplying the current size by our proportion and then converting the float values to int
  • We have resized the image using the new_size values

The ...

Get Hands-On Computer Vision with Julia now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.