예제 #1
0
    def handle_pushButton_viewrawfile_clicked(self, checked):
        dir1 = self.ui.lineEdit_dir.text()
        width = int(self.ui.lineEdit_width.text())
        height = int(self.ui.lineEdit_height.text())
        pattern = self.ui.comboBox_cfa.currentText()
        sensorbit = int(self.ui.comboBox_pixeloffset.currentText()) + 8
        dtype = self.ui.comboBox_inputformat.currentText()
        shift_bits = int(self.ui.comboBox_bitshift.currentText())
        dataformat = int(self.ui.comboBox_dataformat.currentText())
        print(sensorbit)
        iamge = rawimage.read_plained_file(dir1, dtype, width, height,
                                           dataformat)
        rawimage.show_planedraw(iamge, width, height, pattern, sensorbit)

        print("viewrawfile pushButton clicked", checked, self)
예제 #2
0
def test_DPC():
    img = rawimage.read_plained_file("DSC16_1339_768x512_rggb_wait_dpc.raw",
                                     dtype="uint16",
                                     width=768,
                                     height=512,
                                     shift_bits=0)
    global a
    a = 0
    thre_ratio = 1
    # thre_ratio = 300   # MEAN
    result = DPC(img, thre_ratio, mode="extreme", pattern="RGGB")
    rawimage.show_planedraw(result,
                            width=768,
                            height=512,
                            pattern='gray',
                            sensorbit=10,
                            compress_ratio=1)
예제 #3
0
def raw_white_balance(image, type, sensorbit, pattern):
    if sensorbit == 10:
        smax = 1023
    elif sensorbit == 12:
        smax = 4095
    else:
        smax = 255

    R, GR, GB, B, G = rawimage.bayer_channel_separation(image, pattern)
    if type == "grey_world":
        R_gain, G_gain, B_gain = grey_world(R, G, B)
    elif type == "auto_threshold":
        R_gain, G_gain, B_gain = auto_threshold(R, G, B)
    elif type == "grey_world2":
        R_gain, G_gain, B_gain = grey_edge(R, G, B, njet=0, mink_norm=1, sigma=0, saturation_threshold=smax)
    elif type == "shade_of_grey":
        R_gain, G_gain, B_gain = grey_edge(R, G, B, njet=0, mink_norm=5, sigma=0, saturation_threshold=smax)
    elif type == "max_RGB":
        R_gain, G_gain, B_gain = grey_edge(R, G, B, njet=0, mink_norm=-1, sigma=0, saturation_threshold=smax)
    elif type == "grey_edge":
        R_gain, G_gain, B_gain = grey_edge(R, G, B, njet=1, mink_norm=5, sigma=2, saturation_threshold=smax)

    result_image = apply_raw(pattern, R, GR, GB, B, R_gain, G_gain, B_gain, smax)

    # rawimage.show_planedraw(result_image, width=4032, height=2742, pattern="gray", sensorbit=10, compress_ratio=1)
    # rawimage.show_planedraw(result_image, width=4032, height=2752, pattern="GRBG", sensorbit=10, compress_ratio=1)

    h, w = R.shape
    img = np.zeros(shape=(h, w, 3))
    img2 = np.zeros(shape=(h, w, 3))
    img[:, :, 0] = R
    img[:, :, 1] = G
    img[:, :, 2] = B
    R2, GR2, GB2, B2, G2 = rawimage.bayer_channel_separation(result_image, pattern)
    img2[:, :, 0] = R2
    img2[:, :, 1] = GR2
    img2[:, :, 2] = B2

    rawimage.show_planedraw(img, w, h, pattern="color", sensorbit=10, compress_ratio=1)
    rawimage.show_planedraw(img2, w, h, pattern="color", sensorbit=10, compress_ratio=1)
예제 #4
0
                                     dtype="uint16",
                                     width=4032,
                                     height=2752,
                                     shift_bits=0)
    block_size = 16
    pattern = "GRBG"
    shading_R, shading_GR, shading_GB, shading_B = create_lsc_data_base(
        img, block_size, pattern)
    img2 = rawimage.read_plained_file("../pic/D65_4032_2752_GRBG_1_BLC.raw",
                                      dtype="uint16",
                                      width=4032,
                                      height=2752,
                                      shift_bits=0)
    rawimage.show_planedraw(img2,
                            width=4032,
                            height=2752,
                            pattern="gray",
                            sensorbit=10,
                            compress_ratio=1)

    # luma 和color shading
    new_image = apply_shading_to_image_base(img=img2,
                                            block_size=block_size,
                                            shading_R=shading_R,
                                            shading_GR=shading_GR,
                                            shading_GB=shading_GB,
                                            shading_B=shading_B,
                                            pattern="GRBG",
                                            ratio=1)

    print(np.min(new_image), np.max(new_image))
    # rawimage.show_planedraw(new_image, width=4032, height=2752, pattern=pattern, sensorbit=10, compress_ratio=1)
예제 #5
0
    cv.imwrite("../pic/demosaic/" + method + "-demosaic.bmp", cvimage)
    return


if __name__ == "__main__":
    # 制作raw图程序例程
    # maxvalue = 255
    # pattern = "GRBG"
    # image = plt.imread("../pic/demosaic/kodim19.png")
    # if np.max(image) <= 1:
    #     image = image * maxvalue
    # result_image = make_mosaic(image, pattern)
    # rawimage.write_plained_file("kodim191.raw", result_image,  dtype="uint8")

    # demosaic 例程
    pattern = "GRBG"
    file_name = "../pic/demosaic/kodim19.raw"
    image = rawimage.read_plained_file(file_name,
                                       dtype="uint16",
                                       width=512,
                                       height=768,
                                       shift_bits=0)
    h, w = image.shape
    rawimage.show_planedraw(image,
                            w,
                            h,
                            pattern="gray",
                            sensorbit=8,
                            compress_ratio=1)
    test_demosaic(image, pattern, method="ahd")