Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
praneethr86 committed Nov 6, 2018
2 parents acba98f + c57b10e commit a06a15b
Show file tree
Hide file tree
Showing 24 changed files with 609 additions and 378 deletions.
38 changes: 38 additions & 0 deletions Compression_Analysis/PSNR.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import numpy as np
import math
import cv2

def Representational(r,g,b):
return (0.299*r+0.287*g+0.114*b)

def calculate(img):
b,g,r = cv2.split(img)
pixelAt = Representational(r,g,b)
return pixelAt

def main():

#Loading images (orignal image and compressed image)
orignal_image = cv2.imread('orignal_image.png',1)
compressed_image = cv2.imread('compressed_image.png',1)

#Getting image height and width
height,width = orignal_image.shape[:2]

orignalPixelAt = calculate(orignal_image)
compressedPixelAt = calculate(compressed_image)

diff = orignalPixelAt - compressedPixelAt
error = np.sum(np.abs(diff) ** 2)

error = error/(height*width)

#MSR = error_sum/(height*width)
PSNR = -(10*math.log10(error/(255*255)))

print("PSNR value is {}".format(PSNR))


if __name__ == '__main__':
main()

Binary file added Compression_Analysis/compressed_image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Compression_Analysis/example_image.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Compression_Analysis/orignal_image.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 42 additions & 0 deletions Decimal_To_Binary.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
'''
PYTHON 3
Author: Sandeep Pillai (www.github.com/Corruption13)
Program: Decimal to Binary converter.
THis program accepts fractional values, the accuracy can be set below:
'''
decimal_accuracy = 7


def dtbconverter(num): # Function inputs a float value and returns a list as output
# Reasoning for list instead of integer: to avoid integer overflow error.

whole= [] # The part before decimal point
fractional = ['.'] # The part after decimal point

decimal = round(num%1, decimal_accuracy) # Extract fractional number part of decimal
w_num = int(num) # Extract whole number part of decimal.

i=0 # Some fractional decimal numbers have infinite binary values, so we limit this loop below.

#Loop to find binary of decimal part
while(decimal!=1 and i<decimal_accuracy):
decimal = decimal*2
fractional.append(int(decimal//1))
decimal = round(decimal%1, decimal_accuracy)
if(decimal == 0): break # Removes trailing zeros.
i = i + 1

#Loop to find binary of whole number part.
while(w_num!=0):
whole.append(w_num%2)
w_num = w_num//2
whole.reverse()

return whole + fractional ### End of dtbconverter() - 16 lines


#Test lines.
number = float(input("Enter ANY base-10 Number: "))
print("The Binary Equivalant: " , *dtbconverter(number))
Binary file not shown.
66 changes: 0 additions & 66 deletions Google Image Downloader/create_dir.py~

This file was deleted.

133 changes: 0 additions & 133 deletions Google Image Downloader/image grapper.py

This file was deleted.

Loading

0 comments on commit a06a15b

Please sign in to comment.