필터 지우기
필터 지우기

How to add noise to every image in image datastore?

조회 수: 5 (최근 30일)
Csanad Levente Balogh
Csanad Levente Balogh 2020년 12월 6일
댓글: Csanad Levente Balogh 2021년 1월 6일
Hi! I am trying to add gauss noise to every image in image datastore. I want to compare a network trained on normal images with a network trained on only noisy images. A found a soltion here:
The way the noise is added here, is by creating a TransformedDatastore, but I can not use it to train a netvork. It gives the folowing error:
It also threw an error every time I wanted to use it's own object functions, even though I followed the steps in the link above. I basically want to have two image datastores with the same pictures, one with noise, one without noise. Is there a way to do that?

채택된 답변

Shadaab Siddiqie
Shadaab Siddiqie 2020년 12월 9일
From my understanding you want add gaussian noise to all the image, you can use imnoise and loop through all the images from your dataset.
  댓글 수: 1
Csanad Levente Balogh
Csanad Levente Balogh 2021년 1월 6일
Thank you! Yes I assumed it can be done with loops, I just wanted to find a more elegant way. At the end, I used the custom ReadFcn function of the datastore to add the noise. like that:
imageDatastore.ReadFcn = @customReadDatastoreImage
Than the function:
function data = customReadDatastoreImage(filename)
% other settings
% ...
data = imread(filename);
% other preproc (like imresize)
% ...
data = imnoise(data, 'gaussian')
end

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by