フィルターのクリア

Applying 2D filter on RGB image

14 ビュー (過去 30 日間)
Ozan Can Sahin
Ozan Can Sahin 2020 年 10 月 17 日
回答済み: Subhadeep Koley 2020 年 11 月 3 日
Hi all,
I'm having some troubles with applying a vector filter on RGB image, I'm not getting errors but I'm not getting an output which makes sense either. I'm losing at least one of the color channels somehow but I don't know what I'm doing wrong. You can find the application I'm trying to implement in the screenshot attached and I also attach the code to this entry. Looking forward to your help.
For the image I'm trying to upscale, you can get it here.
Thanks in advance

採用された回答

Subhadeep Koley
Subhadeep Koley 2020 年 11 月 3 日
Hi Ozan, the below code might help!
img = imread('kodim07.png');
imshow(img)
img = imresize(img, 2, 'bicubic');
figure
imshow(img)
% define filter kernel
kernel = [1, -5, 20, 20, -5, 1] / 32;
% extracting rgb channels individually
rChannel = img(:, :, 1);
gChannel = img(:, :, 2);
bChannel = img(:, :, 3);
% applying filter to the extracted matrices separately
rChannelNew = filter2(kernel, rChannel);
gChannelNew = filter2(kernel, gChannel);
bChannelNew = filter2(kernel, bChannel);
% concatenate matrices along 3rd dimension
outputImg = cat(3, rChannelNew, gChannelNew, bChannelNew);
% convert the numeric matrix to image
outputImg = mat2gray(outputImg);
figure
imshow(outputImg)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImage Processing Toolbox についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by