MATLAB Answers

How to apply Gaussian filter with for loop without imnoise?

2 ビュー (過去 30 日間)
Hanan Elsayed
Hanan Elsayed 2021 年 9 月 4 日
コメント済み: DGM 2021 年 9 月 5 日
How can I apply Matlab code to do what the imnoise function does but manually using for loop?

採用された回答

DGM
DGM 2021 年 9 月 4 日
編集済み: DGM 2021 年 9 月 5 日
Replicating the gaussian noise functionality of imnoise() does not require any loops. If someone insists that you need to use loops, make sure to let them know they're wrong.
inpict = im2double(imread('cameraman.tif'));
s0 = size(inpict);
% default parameters used by imnoise()
gaumean = 0;
gauvar = 0.01;
outpict = inpict + gaumean + sqrt(gauvar)*randn(s0);
imshow(outpict)
If you want to know how imnoise() does something, open imnoise() and look at $MLROOT/toolbox/images/images/+images/+internal/algimnoise.m
  7 件のコメント
DGM
DGM 2021 年 9 月 5 日
Some functions are very simple (e.g. immse()) and can just be opened and viewed in whole. A lot of functions will call lower-level files, some of which may be viewable m-code. Some may call precompiled binaries which aren't viewable. If you want to find out what something does, start by opening the function file itself and see what it calls. The rest is just digging through the directories in the toolbox.
For a lot of things, you can tell what something does by reading the docs and observing the behavior, although there are plenty of cases where the documentation is incomplete or the wording is vague or misleading in my opinion.

サインインしてコメントする。

その他の回答 (0 件)

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by