Can anyone help me out by explaing the logic or algorithm of the follwing code?Please...
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
I am trying to find out area of a object in an image using MATLAB.But I cannot figurte it out by myshelf. So I visit the website of a MATLAB and find the bellow code. It works for my image but cannot find the logic or the algorithm of the bellow code. But I want to find the logic or algorithm or how the code works. I also comment to the post of the code but noone helps me.I fell so hopeless. So,my humble request to everyone please help me to find the logic of the code to proceed me further. Thank you in advanced.
Here the code is:
input_im=imread('area2.jpg');
input_im=rgb2gray(input_im);
imshow(input_im)
title('Original Object')
sum_of_x_axis=sum(input_im,1);
sum_of_y_axis=sum(input_im,2);
location_of_object_on_x=find(sum_of_x_axis>0);
location_of_object_on_y=find(sum_of_y_axis>0);
seperated_object=input_im(location_of_object_on_y(1):...
location_of_object_on_y(end),location_of_object_on_x(1):...
location_of_object_on_x(end));
figure;
imshow(seperated_object);
title('Seperated Object')
detected_outer_surface=im2bw(seperated_object);
sum_of_outer_space=0;
for i=1:size(seperated_object,1)
if seperated_object(i,1)>0
break
end
for j=1:size(seperated_object,2)
if seperated_object(i,j)>0
break
end
detected_outer_surface(i,j)=1;
sum_of_outer_space=sum_of_outer_space+1;
end
end
for i=1:size(seperated_object,1)
if seperated_object(i,size(seperated_object,2))>0
break
end
for j=size(seperated_object,2):-1:1
if seperated_object(i,j)>0
break
end
detected_outer_surface(i,j)=1;
sum_of_outer_space=sum_of_outer_space+1;
end
end
figure;
imshow(detected_outer_surface)
title('Detected outer Surface which does not belong to object')
Area_of_object=size(seperated_object,1)*size(seperated_object,2);
Area_of_object=Area_of_object-sum_of_outer_space
2 comentarios
Walter Roberson
el 8 de Mayo de 2022
Editada: Image Analyst
el 8 de Mayo de 2022
You were replied to, and then you did not return for over a week to ask for clarification. You then posted here before asking for clarification there.
Walter Roberson
el 8 de Mayo de 2022
Please be more specific about what parts you are looking assistance with. At the moment it looks like you want the 50 lines of code to be explained line by line. Explaining 50 lines of code in detail is not a productive use of our time. We have no idea what you understand or what your experience is, so we would have to assume that you do not know anything about the fundamentals of mathematics and explain everything from the beginning, such as how
sum_of_outer_space = sum_of_outer_space + 1
actually works. Number systems, positional arithmetic, two's compliment, floating point representation, the history of infinity, whether infinity actually exists, Fields and Rings, transitive and commutative operations... and so on.
We cannot even "Explain It Like I Am Five": without guidance from you, we cannot assume that you even have that much experience, and have to start back at basic counting.
Now, if you had specific questions such as what "break" means, we could be much more focused.
Respuestas (1)
Image Analyst
el 8 de Mayo de 2022
Editada: Image Analyst
el 8 de Mayo de 2022
Again, this was already answered here by me:
where I told you to use my code and not the (bad) code you are trying to use here and there in your other question. Why are you trying to use this amateurish code rather than mine (who has over 40 years of image processing experience)?
0 comentarios
Ver también
Categorías
Más información sobre Get Started with MATLAB en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!