Код: Выделить всё
# import necessary packages
# reading/writing image files
from skimage import io
from skimage import color
# displaying images and plots
import matplotlib as mpl
import matplotlib.pyplot as plt
# array operations
import numpy as np
# mathematical calculations
import math
# data frame operations
import pandas as pd
# STEP 2 Define a vector source by combining two consecutive pixels
# and calculate the probabilities of these vector symbols
# ADD YOUR CODE HERE
# notes:
# since each pixel has 8 intensity levels, there will be 8x8 = 64 symbols in the vector source.
# the symbols for the vector source could be represented as "aa, ab, ac, ..., hf, fg, hh."
# there are a total of 512*512/2 = 131,072 sample vectors in the input image to calculate the histogram
# calculate the histogram of the vector symbols
# obtain the pdf by normalizing the histogram
# plot the pdf of this vector source
Подробнее здесь: https://stackoverflow.com/questions/785 ... y-function