3
>>> import cv2
>>> img = cv2.imread("messi5.jpg", cv2.CV_LOAD_IMAGE_COLOR)
>>> row, column, depth = img.shape
>>> row, column, depth
(308, 450, 3)       # Dimension is right same as reported by mac
>>> row*column*depth
415800
>>> float(row*column*depth)/1024
406.0546875

My mac report different size:

My mac report different size:

Hackaholic
  • 19,069
  • 5
  • 54
  • 72
  • jpeg is a _compressed_ format. When you load the image with `imread` you have the BGR _uncompressed_ image – Miki Apr 26 '16 at 10:30
  • 1
    Whats the exact question here? – linusg Apr 26 '16 at 10:31
  • Using python it show different size and Mac report different size, any explanation??, its so clear in the post. – Hackaholic Apr 26 '16 at 10:32
  • I think in Python OpenVC you get the size of the representation as pixels – linusg Apr 26 '16 at 10:35
  • to get the size in kb, you just need to check the [size of the file](http://stackoverflow.com/q/2104080/5008845), not load the image (that decompresses from jpg and _converts_ to a BGR image) – Miki Apr 26 '16 at 10:50
  • Why you find the image size like this ? try this `float(img.size)/1024` – Rahul K P Apr 26 '16 at 10:53
  • @RahulKP that doesn't make any sense – Miki Apr 26 '16 at 10:53
  • @Miki is right. JPG is compressed. You are calculating the amount of data that uses in memory once it is loaded and uncompressed. You may try your algorithm using an uncompressed format, however probably it will differ since the files have a header too.... – api55 Apr 26 '16 at 15:36
  • `os.path.getsize(path)` – wyx Jun 16 '19 at 03:17

0 Answers0