simplest adaptive thresholding custom code

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

 Respuesta aceptada

KALYAN ACHARJYA
KALYAN ACHARJYA el 30 de Jun. de 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 comentarios

Matpar
Matpar el 30 de Jun. de 2019
Editada: Matpar el 30 de Jun. de 2019
Lol!! thanks for responding @ KALYAN ACHARJYA really appreciate it!!
I know my code is a mess and I am trying to understand what I am doing!
Can you give me an example of what it should be? So in the future I can reference that example and learn progressively!!
A simple for loop calculating the mean and standard deviation is my aim!!
Can you or anyone provide and example of this please? So that I can learn the processes and it's requirements!
Thank you for aacknowledging my digital presence!!
KALYAN ACHARJYA
KALYAN ACHARJYA el 30 de Jun. de 2019
A simple for loop calculating the mean and standard deviation is my aim!!
Lest one objective at a time: Mean
Input data?? Mean of ??
Matpar
Matpar el 30 de Jun. de 2019
Ok! I am following your lead i really would like to learn and understand this @KALYAN ACHARJYA! Seeing that my values and understanding is off, you chose! Thank you for responding!
KALYAN ACHARJYA
KALYAN ACHARJYA el 30 de Jun. de 2019
Editada: KALYAN ACHARJYA el 30 de Jun. de 2019
Mean of what?
Requested you to look here Mean
and standard deviation here
Any specific, doubt, let us know?
Matpar
Matpar el 30 de Jun. de 2019
Thanks once more @ KALYAN ACHARJYA! I have seen those/your example, that is not my issue. I am having trouble doing it as a for loop! implementing the mean in a for loop as well as the standard deviation. I was hoping you can provide a demonstration of the task in the simplest form so that I can comprehend it. I have been searching online for an example that shows this so that i can go over it on my own, so that it sticks....
Please assist anticipating your response positively!
KALYAN ACHARJYA
KALYAN ACHARJYA el 30 de Jun. de 2019
Editada: KALYAN ACHARJYA el 30 de Jun. de 2019
Thats why I am asking, please provide the input? Mean of what?? Any array?
Pls elaoborate with example (Maths)?
Matpar
Matpar el 30 de Jun. de 2019
Thanks for responding @ KALYAN ACHARJYA
can you help me do a for loop for these arrays please?
threshold = 30
Standard Dev x = [2 2 4; 3 1 2; 6 2 3];
utilisng this mean x = [0 1 1; 1 1 2]
KALYAN ACHARJYA
KALYAN ACHARJYA el 30 de Jun. de 2019
Editada: KALYAN ACHARJYA el 30 de Jun. de 2019
Sorry I didnot get the question. Loop is use to do just reapeating task. The question is, loop use to calculate ??
I assumed, you know the basic of loop.
Matpar
Matpar el 30 de Jun. de 2019
yes I understand the basic loop but I am trying to understand how to do adaptive threshold via a for loop!! To do this adaptive threshold, does it require calculating the mean as well as standard deviation? I have been reading but some how I am not getting it. I deceided to see this happen as an example so that it would be a little clearer!
Thank for responding and acknowledging me!
Matpar
Matpar el 30 de Jun. de 2019
Editada: Matpar el 30 de Jun. de 2019
this is normal thresholding, I am not sure how to do the mean calculation in the same code for adaptive thresholding, This where i reach :
function Car = Thresholding(Gcar)
[rows, cols] = size(Gcar);
Car = zeros(rows, cols);
for i = 1:r
for j = 1:c
if Gcar(i,j) > 100
Car(i,j) = 1;
end
end
end
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 el 1 de Jul. de 2019
Editada: Matpar el 1 de Jul. de 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!!
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{:});

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre File Operations en Centro de ayuda y File Exchange.

Preguntada:

el 30 de Jun. de 2019

Comentada:

el 1 de Jul. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by