Reading and Compressing a picture with RLE

自作多情 提交于 2021-01-27 14:37:44

问题


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?


回答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.



来源:https://stackoverflow.com/questions/22456480/reading-and-compressing-a-picture-with-rle

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!