我的分块图像数据预处理数据对比

        imgName = filepaths[img_no]

        Img = cv2.imread(imgName, 1)
        #   Img为256,256,3
        #   Img_yuv=Img_rec_yuv为256,256,3
        Img_yuv = cv2.cvtColor(Img, cv2.COLOR_BGR2YCrCb)
        Img_rec_yuv = Img_yuv.copy()
        #   Iorg的shape为256*256
        Iorg_y = Img_yuv[:,:,0]
        #   Iorg_y的shape为256*256,Ipad为264,264,imread_CS_py(Iorg_y)对图像右边和下面补零了,264/33=8
        [Iorg, row, col, Ipad, row_new, col_new] = imread_CS_py(Iorg_y)
        Icol = img2col_py(Ipad, 16).transpose()/255.0
        #   Icol  为64*1089
        Img_output = Icol
        Img_output = torch.from_numpy(Img_output).type(torch.FloatTensor)
        Img_output= Img_output.to(device)
        #   分组start

        batch_y = torch.mm(Img_output, torch.transpose(Phi, 0, 1))  # 观测值y.每一行为一个图像块对应的观测值
        start = time()
        batch_x0 = torch.mm(batch_y, torch.transpose(Qinit, 0, 1)) 

关于img,其shape为<class ‘tuple’>: (512, 512, 3)

在这里插入图片描述
关于Img_yuv,其shape为<class ‘tuple’>: (512, 512, 3)
在这里插入图片描述
关于Iorg_y,其shape为<class ‘tuple’>: (512, 512)
在这里插入图片描述
关于Iorg,其shape为<class ‘tuple’>: (512, 512)
在这里插入图片描述关于Icol,其shape为<class ‘tuple’>: (1024, 256)
在这里插入图片描述

关于Img_output,其shape为torch.Size([1024, 256])

tensor([[0.4980, 0.4824, 0.4902,  ..., 0.5176, 0.5059, 0.5020],
        [0.4745, 0.4941, 0.5059,  ..., 0.5216, 0.5216, 0.5176],
        [0.5373, 0.5059, 0.5255,  ..., 0.5373, 0.5137, 0.5451],
        ...,
        [0.5373, 0.5059, 0.4745,  ..., 0.4314, 0.4157, 0.4314],
        [0.4118, 0.4235, 0.4431,  ..., 0.3569, 0.3412, 0.3294],
        [0.3725, 0.3647, 0.3804,  ..., 0.4000, 0.3725, 0.3804]])

关于batch_y,是一个batch对应的观测值。

其值为:

tensor([[-12.4335,   5.4173,  -1.6632,  ...,  -1.2565,  -7.1197, -11.5201],
        [-12.9857,   5.7168,  -1.7476,  ...,  -1.0469,  -7.6428, -12.2431],
        [-13.0031,   5.5625,  -2.0829,  ...,  -1.1548,  -7.3446, -11.7510],
        ...,
        [-13.4243,   4.2034,  -2.0059,  ...,  -1.8164,  -6.5609, -14.5081],
        [-11.6454,   3.7870,  -1.3004,  ...,  -0.6608,  -7.6010, -11.0177],
        [-10.2765,   3.7000,  -2.0770,  ...,   0.1464,  -6.1413,  -9.3848]])

其shape为:torch.Size([1024, 26])
行为1024,是因为一张大的图片裁成了1024张图像块,1024张小图像块作为一个batch,输入模型中。【每一行代表一张图像块】。故有1024行。
列为26,这是因为图像块拉成一列后,有256个像素。用10%的采样率采样,余数部分大于0.5则向上取整,小于0.5向下取整。256X10%=25.6,故向上取整为26。即采26个像素点。

关于 batch_x0 ,是初始重建值。 其shape为torch.Size([1024, 256])
其值为

tensor([[0.4881, 0.4879, 0.4881,  ..., 0.5091, 0.5073, 0.5038],
        [0.4959, 0.5054, 0.5127,  ..., 0.5448, 0.5428, 0.5423],
        [0.5261, 0.5209, 0.5226,  ..., 0.5163, 0.5115, 0.5121],
        ...,
        [0.5045, 0.5056, 0.4878,  ..., 0.4403, 0.4423, 0.4546],
        [0.4088, 0.3948, 0.3913,  ..., 0.3445, 0.3658, 0.3876],
        [0.3316, 0.3277, 0.3249,  ..., 0.4756, 0.4760, 0.4601]])

在训练中比较的是模型训练得到图像块的输出与Img_output所对应的值之间的差值,希望差值尽量小,也就是loss损失尽量小。

在测试中,比较的是拼接好的整张重建图像和原大图比较。如

        rec_PSNR = psnr(X_rec*255, Iorg.astype(np.float64))
        rec_SSIM = ssim(X_rec*255, Iorg.astype(np.float64), data_range=255)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值