コード例 #1
0
import utils
import numpy as np
import sys

fileName = sys.argv[1]

oldArray = utils.read_image_as_bw(fileName)
newArray = np.copy(oldArray)

shape = oldArray.shape
height = shape[0]
width = shape[1]

for i in range(height):
    for j in range(width):
        newArray[i][j] = oldArray[-i][j]

outPath = 'images/output/' + fileName

utils.show_image(newArray)
utils.save_bw_image(newArray, outPath)
コード例 #2
0
    elif blur.startswith("mean"):
        n = blur[4:]
        n = int(n)
        img = mean_blur(img, n)

    if method == 'sobel':
        X_edges, Y_edges = sobel_edges_x_and_y(img)
    elif method == 'central_difference':
        X_edges, Y_edges = central_diff_edges_x_and_y(img)

    magnitudes = compute_edge_magnitudes(X_edges, Y_edges)
    directions = compute_edge_directions(X_edges, Y_edges)
    img = suppress_edges(magnitudes, directions)
    magnitudes[img == 1] = 0
    magnitudes = magnitudes * (255.0 / magnitudes.max())

    threshImg = np.copy(magnitudes)
    threshImg[threshImg > t] = 255
    threshImg[threshImg < t] = 0
    return threshImg


path = r'C:\Users\Blake\Desktop\Vision\Lab 4\images\input\Piano.jpg'
img = utils.read_image_as_bw(path)

img = find_edges(img, 'sobel', 'gaussian3', 40)

utils.show_image(img)

#savePath = path = r'C:\Users\Blake\Desktop\Vision\Lab 4\images\output\Piano_edges.jpg'
#utils.save_bw_image(img, savePath)
コード例 #3
0
            #number is 9 - right side
            final.append(9)
        elif currSegment == [0, 0, 0, 255, 255, 0, 255]:
            #number is 0 - right side
            final.append(0)
        else:
            a = a
            #print('broke')
            final.append('broke')
        #print(currSegment)
        currSegment = []
        
    if flipped == True:
        final.reverse()

    return final
                
        
        
    
imgPath = r'C:\Users\Blake\Desktop\Vision\Lab 6\images\easy.jpg'
img = utils.read_image_as_bw(imgPath)
img = np.rot90(img, 3)
barcode = find_barcode(img)  
connComp = getLargestCC(barcode)
bar = getBarcode(img, connComp)
print(readBarcode(bar))