Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a code to compress a binary image using Run length Encoding. encode image function: Write your code to compute run length code for the

Write a code to compress a binary image using Run length Encoding.

  • encode image function:
    • Write your code to compute run length code for the binary image. The input to your function will be a binary image(0's and 255's) and output a run length code.
      • decode image function: Write your code to get binary image from run length code returned by encode image funtion. The input of the function is run length code, height and width of the binary image The output of the function is binary image reconstructed from run length code.

Do not use any in-built functions from opencv and numpy. In general, you can use function from math library. Functions allowed np.array(), np.matrix(), np.zeros(), np.ones(), cv2.imread(), cv2.namedWindow(), cv2.waitKey().

import numpy as np class runlength: def encode_image(self,binary_image): """ Compress the image takes as input: image: binary_image returns run length code """ return np.zeros(100) #replace zeros with rle_code def decode_image(self, rle_code, height , width): """ Get original image from the rle_code takes as input: rle_code: the run length code to be decoded Height, width: height and width of the original image returns decoded binary image """ return np.zeros((100,100), np.uint8) #replace zeros with image reconstructed from rle_Code 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Security

Authors: Alfred Basta, Melissa Zgola

1st Edition

1435453905, 978-1435453906

More Books

Students also viewed these Databases questions