kernel_c3 = np.array([ [0, 0, 2], [0, -1, 0], [-1, 0, 0] ]) _offset = 1 # Original name = "monkey.jpg" _img = util.read_image(name) cv.imshow("Original", _img) # Gray img_gray = color.rgb_to_gray(_img) cv.imshow("Gray", img_gray) util.write_image("gray-" + name, img_gray) # Convolution Kernel c1 util.do_convolution_show_and_write(_img, kernel_c1, "conv-c1-" + name, _offset) # Convolution Gray Kernel c1 util.do_convolution_show_and_write(img_gray, kernel_c1, "conv-c1-gray-" + name, _offset) # 2 util.do_convolution_show_and_write(_img, kernel_c2, "conv-c2-" + name, _offset) util.do_convolution_show_and_write(img_gray, kernel_c2, "conv-c2-gray-" + name, _offset) # 3 util.do_convolution_show_and_write(_img, kernel_c3, "conv-c3-" + name, _offset) util.do_convolution_show_and_write(img_gray, kernel_c3, "conv-c3-gray-" + name, _offset)
import util name = "skate.jpg" original = util.read_image(name) # Processing red_band = color.red_band(original) green_band = color.green_band(original) blue_band = color.blue_band(original) mono_red = color.monochromatic_red(original) mono_green = color.monochromatic_green(original) mono_blue = color.monochromatic_blue(original) gray = color.rgb_to_gray(original) # Save util.write_image("red-" + name, red_band) util.write_image("green-" + name, green_band) util.write_image("blue-" + name, blue_band) util.write_image("mono-red-" + name, mono_red) util.write_image("mono-green-" + name, mono_green) util.write_image("mono-blue-" + name, mono_blue) util.write_image("gray-" + name, gray) # Show cv.imshow('Red', red_band) cv.imshow('Green', green_band)