Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于测试的困惑 #26

Open
JYP2011 opened this issue Oct 11, 2018 · 6 comments
Open

关于测试的困惑 #26

JYP2011 opened this issue Oct 11, 2018 · 6 comments

Comments

@JYP2011
Copy link

JYP2011 commented Oct 11, 2018

Hi,
对于下面的代码片段比较困惑,为什么在将rgb图片转换为ycbcr时要先除以255,最后为了得到y通道还要乘以255呢?
我不明白这有什么意义,按照矩阵运算,除以255然后乘以255.应该没差别才对。
但是事实是,您的做法似乎保证了非负。
打扰了。

clear;close all;
%% settings
folder = 'Set5';

%% generate data
filepaths = [];
filepaths = [filepaths; dir(fullfile(folder, '*.bmp'))];

scale = [2, 3, 4];

for i = 1 : length(filepaths)
    im_gt = imread(fullfile(folder,filepaths(i).name));
    for s = 1 : length(scale) 
        im_gt = modcrop(im_gt, scale(s));
        im_gt = double(im_gt);
        im_gt_ycbcr = rgb2ycbcr(im_gt / 255.0);
        im_gt_y = im_gt_ycbcr(:,:,1) * 255.0;
        im_l_ycbcr = imresize(im_gt_ycbcr,1/scale(s),'bicubic');
        im_b_ycbcr = imresize(im_l_ycbcr,scale(s),'bicubic');
        im_l_y = im_l_ycbcr(:,:,1) * 255.0;
        im_l = ycbcr2rgb(im_l_ycbcr) * 255.0;
        im_b_y = im_b_ycbcr(:,:,1) * 255.0;
        im_b = ycbcr2rgb(im_b_ycbcr) * 255.0;
        last = length(filepaths(i).name)-4;
        filename = sprintf('Set5_mat/%s_x%s.mat',filepaths(i).name(1 : last),num2str(scale(s)));
        save(filename, 'im_gt_y', 'im_b_y', 'im_gt', 'im_b', 'im_l_ycbcr', 'im_l_y', 'im_l');
    end
end
@twtygqyy
Copy link
Owner

twtygqyy commented Oct 11, 2018

Hi, for rgb2ycbcr function in Matlab, if the input is uint8 (0~255), YCBCR will be uint8, while if the input is a double, YCBCR will be double. The 255.0 division is just for 0,1 normalization, you can do without it.

@JYP2011
Copy link
Author

JYP2011 commented Oct 12, 2018

Hi, for rgb2ycbcr function in Matlab, if the input is uint8 (0~255), YCBCR will be uint8, while if the input is a double, YCBCR will be double. The 255.0 division is just for 0,1 normalization, you can do without it.

可是作normalization和不作nomalization的得到结果不一样呀,我做过测试,相差很多。

@twtygqyy
Copy link
Owner

训练的时候input的数据必须是normalized,范围是0~1 不然输入的distribution差别太大

@blueardour
Copy link

@JYP2011 @twtygqyy In your experience, which is better for nomalization and non-nomalization?

The input requirement to be nomalized into 0~1 probably might be relaxed by adding a batchnorm layer.

@twtygqyy
Copy link
Owner

twtygqyy commented May 3, 2019

For super-resolution problem, batch_norm is not recommended because it normalizes the intensity level across samples in each batch.

@Missdonghui
Copy link

hi,Why did I encounter this problem? May I ask how did you do it in the test? I have consulted some solutions, but they are still useless.
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 918: ordinal not in range(128)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants