MATLAB Answers

simplest adaptive thresholding custom code

53 views (last 30 days)
Matpar
Matpar on 30 Jun 2019
Commented: Matpar on 1 Jul 2019
Hi all,
I got this far with the adaptive thresholding, Can a professional explain my errors please?
i am trying to do an adaptive thresholding via (Custom For Loop)manual coding!!
I am not sure if this can work! need a break down of what should happen please!!
Thanks in advance!!
function adthres;
[row col]=size(x);
for i=1:1:n
for j=1:n
x = i - n/2;
y = j - n/2;
j(i,j) = exp(-(x*x)/two_sigma_sq);
end
end
end

  0 Comments

Sign in to comment.

Accepted Answer

KALYAN ACHARJYA
KALYAN ACHARJYA on 30 Jun 2019
adaptive thresholding menas, the threshold value is not fixed, its depends on image or input data
In the first view, This code is messed. As you defined j=1:n, here j is scalar, also j(i,j)>> Here j >> representing vector. I didnot find any statement, which relate to calculate the threshold value or replacing vector elements based the threshold.
some_vector(i,j)=exp(-(x*x)/two_sigma_sq);
This statement finding the each element of 2D vector/matrix

  13 Comments

Image Analyst
Image Analyst on 30 Jun 2019
Replace all that with these simple two lines of code:
function Car = Thresholding(Gcar)
Car = Gcar > 100;
No for loops at all needed.
Matpar
Matpar on 1 Jul 2019
Hi thanks for responding @ Image Analyst! But i still ould liketo understand it utilisng the for loops!! can you guide me in the right direction please?
I understood the;
function Car = Thresholding(Gcar)
Car = Gcar > 100;
but still would like to solve the adaptive threshold via for loop and thanks in advance for responding and acknowledging my comments and anwers!!
Matpar
Matpar on 1 Jul 2019
Hi @ Image Analysis,
Can you help me understand this Error Please?
Error using images.internal.imageDisplayValidateParams>validateCData (line 119)
If input is logical (binary), it must be two-dimensional.
Error in images.internal.imageDisplayValidateParams (line 27)
common_args.CData = validateCData(common_args.CData,image_type);
Error in images.internal.imageDisplayParseInputs (line 78)
common_args = images.internal.imageDisplayValidateParams(common_args);
Error in imshow (line 246)
images.internal.imageDisplayParseInputs({'Parent','Border','Reduce'},preparsed_varargin{:});

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by