uz_assignments/assignment2/solution.py

41 lines
1.4 KiB
Python
Raw Normal View History

2022-10-26 16:08:01 +02:00
import numpy as np
import numpy.typing as npt
from matplotlib import pyplot as plt
import random
import cv2
import uz_framework.image as uz_image
#################################################################
# EXCERCISE 1: Exercise 1: Global approach to image description #
#################################################################
def ex1():
one_a()
def one_a():
"""
Firstly, you will implement the function myhist3 that computes a 3-D histogram
from a three channel image. The images you will use are RGB, but the function
should also work on other color spaces. The resulting histogram is stored in a 3-D
matrix. The size of the resulting histogram is determined by the parameter n_bins.
The bin range calculation is exactly the same as in the previous assignment, except
now you will get one index for each image channel. Iterate through the image pixels
and increment the appropriate histogram cells. You can create an empty 3-D numpy
array with H = np.zeros((n_bins,n_bins,n_bins)). Take care that you normalize
the resulting histogram.
"""
test_image = uz_image.imread('./data/images/museum.jpg', uz_image.ImageType.float64)
uz_image.get_image_bins_ND(test_image, 10)
plt.imshow(test_image)
plt.show()
# ######## #
# SOLUTION #
# ######## #
def main():
ex1()
if __name__ == '__main__':
main()