3

Currently I am learning python and I'd like to get a little bit more into Data Compression. So I decided to try to code Run-Length Encoding(RLE).

From what I've read it can be useful when you try to compress pictures.

I would like to know what would be the easiest image-file-type for a beginner? How can I read out pixel RGB values or similar from a picture with python?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Doc
  • 345
  • 4
  • 17
  • The easiest format would be BMP since generally it is not compressed in any way. That said, this is not a suitable question for StackOverflow. – Selcuk Mar 17 '14 at 14:20

1 Answers1

1

As for the second part of your question: I would highly recommend OpenCV. It is very power for image processing and analysis. A very basic example of getting the pixel values of an image in Python using OpenCV:

import cv2

image = cv2.imread("some_image.jpg")
image[x, y, z]

This will return the value of the pixel at x, y, z coordinates. Note that indexing begins at 0 so if you want to access the third RGB component, you have to do image[x, y, 2] where x and y are the line and column.

Drewness
  • 5,004
  • 4
  • 32
  • 50