Commit d212fe93 authored by 袁通's avatar 袁通
Browse files

update

parent 80df0ef0
Loading
Loading
Loading
Loading
(667 KiB)

File changed.

No diff preview for this file type.

+196 KiB

File added.

No diff preview for this file type.

+720 KiB (1.31 MiB)

File changed and moved.

No diff preview for this file type.

+17 −3
Original line number Diff line number Diff line
@@ -12,7 +12,7 @@ import matplotlib.pyplot as plt
def sum(histogram, index):
    sum = 0
    for i in range(index):
        sum = sum + histogram[i]
        sum += histogram[i]
    # print(sum)
    return sum

@@ -23,6 +23,15 @@ def match(histogram, pixel):

    return 0;

def spec_hist():
    spec_hist = np.full((256), 1/256)

    spec_hist[200:255] = spec_hist[200:255]*5

    spec_hist = spec_hist/np.sum(spec_hist)

    return spec_hist

def hist_match_11810818(input_image, spec_hist):

# Define outputs
@@ -47,9 +56,11 @@ def hist_match_11810818(input_image, spec_hist):


    # histogram matching
    G_z = np.zeros((256,), dtype=np.uint8)
    G_z = np.zeros((256), dtype=np.uint8)
    

    for i in range(256):
        # print((256-1)*sum(spec_hist, i))
        G_z[i] = (256-1)*sum(spec_hist, i)
    print(G_z)

@@ -67,7 +78,8 @@ def hist_match_11810818(input_image, spec_hist):

if __name__ == '__main__':

    [output_image_1, output_hist_1, input_hist_1] = hist_match_11810818(io.imread("Q3_2.tif"), np.full((256,), 1/256))
    
    [output_image_1, output_hist_1, input_hist_1] = hist_match_11810818(io.imread("Q3_2.tif"), spec_hist())
    
    # Print result
    io.imsave("Q3_2_11810818.tif", output_image_1)
@@ -77,4 +89,6 @@ if __name__ == '__main__':
    in_1.plot(np.arange(256), input_hist_1)
    out_1.plot(np.arange(256), output_hist_1)

    plt.show()

Loading