예제 #1
0
from Image import ImageObject
from Histogram import rgb_histogram

path = "images/"
image = ImageObject(path + "eu.png")
image.load_image()
#image.set_size(512, 512)

sample_grid = int(input("Enter an even value for sample grid: "))
while sample_grid % 2 != 0:
    sample_grid = int(input("Enter an even value for sample grid: "))

level = int(input("Enter an even value for levels of RGB: "))
while level % 2 != 0:
    level = int(input("Enter an even value for levels of RGB: "))

image.discretize(sample_grid)
image.quantize(level)

rgb_histogram(image)
image.save_image(
    path + f"color/color_quantize{level}_discretize{sample_grid}_cat.png")
image.show_image()
예제 #2
0
from Image import ImageObject
from Histogram import gray_histogram
from copy import deepcopy
import matplotlib.pylab as plt

path = "images/"
image = ImageObject(path + "greyscale.png")
image.load_image()
image.set_size(512, 512)
image.set_image_to_gray()
image.save_image(path + "pb.png")
old_image = deepcopy(image)

image.equalization()
image.save_image(path + "equalization/equalization.png")

old_image.show_image()
gray_histogram(old_image, 'r')

image.show_image()
gray_histogram(image, 'gray')

plt.show()
예제 #3
0
from Image import ImageObject
from Histogram import gray_histogram
from copy import deepcopy
import matplotlib.pylab as plt

path = "images/"
image = ImageObject(path + "greyscale.png")
image.load_image()
image.set_size(512, 512)
image.set_image_to_gray()
image.save_image(path + "pb.png")
old_image = deepcopy(image)

image.stretch(0.001)
image.save_image(path + "stretch/normal_stretch.png")

image.show_image()
gray_histogram(image, 'b')

image.stretch(0.125)
image.save_image(path + "stretch/stretch25.png")

old_image.show_image()
gray_histogram(old_image, 'r')

image.show_image()
gray_histogram(image, 'gray')

plt.show()
예제 #4
0
from Image import ImageObject
from Histogram import gray_histogram
from copy import deepcopy
import matplotlib.pylab as plt

path = "images/"
image = ImageObject(path + "greyscale.png")
image.load_image()
image.set_size(512, 512)
image.set_image_to_gray()
image.save_image(path + "pb.png")
old_image = deepcopy(image)

print("""What operation do you want to perform?
    1.Sum
    2.Subtraction
    3.Multiplication
    4.Division""")
option = 0
while not int(option) in range(1, 5):
    option = int(input(""))
highlight = float(input("Enter a highlight value: "))

if option == 1:
    image.linearSum(highlight)
    name = "linears/sum_h"
    image.save_image(path + name + f"{int(highlight)}.png")
if option == 2:
    image.linearSub(highlight)
    name = "linears/sub_h"
    image.save_image(path + name + f"{int(highlight)}.png")
예제 #5
0
from Image import ImageObject
import numpy as np

path = "images/"
image = ImageObject(path + "greyscale.png")
image.load_image()
image.set_size(512, 512)
image.set_image_to_gray()
image.save_image(path + "pb.png")

weighted_average = [[1.5, 2.0, 2.5], [2.0, 4.0, 2.0], [1.5, 2.0, 1.5]]
laplace = [[0.0, -1.0, 0.0], [-1.0, 4.0, -1.0], [0.0, -1.0, 0.0]]
sharpen = [[-1.0, -1.0, -1.0], [-1.0, 9.0, -1.0], [-1.0, -1.0, -1.0]]
border_detection = [[-1.0, -1.0, -1.0], [-1.0, 8.0, -1.0], [-1.0, -1.0, -1.0]]
sobel_a = np.square([[-1.0, -2.0, -1.0], [0.0, 0.0, 0.0],
                     [1.0, 2.0, 1.0]])  #primeira matriz elevada ao quadrado
sobel_b = np.square([[-1.0, 0.0, -1.0], [-2.0, 0.0, 2.0],
                     [-1.0, 0.0, 1.0]])  #segunda matriz elevada ao quadrado
final_sobel = np.sqrt(
    sobel_a +
    sobel_b)  #resultado final é a raiz da soma das matrizes anteriores


def saturate(value):
    if value > 255:
        return 255
    if value < 0:
        return 0
    return value

예제 #6
0
from Image import ImageObject
from Histogram import gray_histogram

path = "images/"
image = ImageObject(path + "cat.png")
image.load_image()
image.set_size(512, 512)
image.set_image_to_gray()
image.save_image(path + "_pb.png")

sample_grid = int(input("Enter an even value for sample grid: "))
while sample_grid % 2 != 0:
    sample_grid = int(input("Enter an even value for sample grid: "))

level = int(input("Enter an even value for levels of gray: "))
while level % 2 != 0:
    level = int(input("Enter an even value for levels of gray: "))

image.gray_discretize(sample_grid)
image.gray_quantize(level)

gray_histogram(image)
image.save_image(path +
                 f"/gray/gray_quantize{level}_discretize{sample_grid}_cat.png")
image.show_image()
예제 #7
0
from Image import ImageObject
from Histogram import gray_histogram
from copy import deepcopy
import matplotlib.pylab as plt

path = "images/"
image = ImageObject(path + "greyscale.png")
image.load_image()
image.set_size(512, 512)
image.set_image_to_gray()
image.save_image(path + "pb.png")
old_image = deepcopy(image)

image.transformation()
image.save_image(path + "linears/transformed.png")

old_image.show_image()
gray_histogram(old_image, 'r')

image.show_image()
gray_histogram(image, 'gray')

plt.show()