DnCNN - how does denoiseImage work?

조회 수: 5 (최근 30일)
Evgenye Phan
Evgenye Phan 2020년 8월 21일
답변: Gayathri 2025년 6월 4일
I have a question related to DnCNN. The architecture of DnCNN has the input image layer with the size of [50,50,1]. But when using the trained model for prediction by using the function denoiseImage, it can be applied to images of arbitrary sizes. Meawhile, I can't do the same thing by using the function predict since the input image and the input layer have different sizes. Anyone can explain me how the function denoiseImage works. Does it divide the input image into patches or replace the input image layer? Thank you.

답변 (1개)

Gayathri
Gayathri 2025년 6월 4일
As of MATLAB R2024b, I am able to use both "denoiseImage" and "predict" function, without any errors for different image dimensions when using the pretrained "DnCNN" model.
Please refer to the below code which illustrates the same.
% Load pre-trained DnCNN model
net = denoisingNetwork('dncnn'); % Loads MATLAB's pre-trained DnCNN for Gaussian noise
% Read input image
inputImagePath = 'mri.tif'; % Replace with your image path
I = imread(inputImagePath);
disp(size(I));
128 128
% Convert to grayscale if needed (DnCNN typically works on grayscale images)
if size(I, 3) == 3
I = rgb2gray(I);
end
I = im2double(I); % Convert to double for processing (range [0, 1])
% Add synthetic Gaussian noise
noiseLevel = 25 / 255; % Noise standard deviation
noisyI = imnoise(I, 'gaussian', 0, noiseLevel^2);
out=predict(net, noisyI);
disp("Predict function worked")
Predict function worked
% Denoise the image using DnCNN
denoisedI = denoiseImage(noisyI, net);
disp("denoiseImage function worked")
denoiseImage function worked
What I understand is that, "denoiseImage" function do not work on patches and work on the whole image. It uses the predict function to make the predictions.
You can read more about "denoiseImage" function using the link below.

카테고리

Help CenterFile Exchange에서 Deep Learning for Image Processing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by