필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

CAN ANY ONE TELL ME WHAT IS THIS PART OF CODE DOING??

조회 수: 2 (최근 30일)
Ayesha ayub
Ayesha ayub 2014년 12월 8일
마감: MATLAB Answer Bot 2021년 8월 20일

답변 (1개)

Guillaume
Guillaume 2014년 12월 8일
편집: Guillaume 2014년 12월 8일
This badly written code recolour a rectangle of 4 rows by 8 column above the centroid of the largest objects. The red and green channels of that rectangle are set to 0, the blue is set to 255.
I say badly written since none of the for loops are required (the second one is particularly absurd). The first loop could just be replaced with:
[armax, armaxloc] = max(ar);
%no need to calculate mx (which by the way is just mx = numel(ar))
centroid = stats(armaxloc).Centroid;
The second loop is just:
i_aft(y-4:y, x-4:x+4, [1 2]) = 0; %set red and green channel to 0
i_aft(y-4:y, x-4:x+4, 3) = 255; %set blue channel to 255
Note that the above, just like the original code will give an error if the centroid is less than 4 pixels away from the left, top or right edge of the image.
Possibly, the original author intended to recolour a square around the centroid, but that's not what the code is doing.
  댓글 수: 1
Image Analyst
Image Analyst 2014년 12월 8일
Looks like he's trying to burn a blue box into the RGB "after" image. I'm not sure why. I'd probably just use plot(x,y,'bs', 'LineWidth', 4, 'MarkerSize', 10), or rectangle() or line(), to place a blue rectangle in the overlay above the image.

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by