What is the use of "maxidx = max(A(:))+1" in the below code ? How does it work? Any alternate syntax for the below function?
조회 수: 11 (최근 30일)
이전 댓글 표시
Samson David Puthenpeedika
2021년 11월 8일
댓글: Samson David Puthenpeedika
2021년 11월 9일
The question and code is given below :-
input: spine.tif from MATLAB
Read the indexed image with the associated colormap, show the colormap functions of all color channels with the corresponding color;
[A,map]=imread("spine.tif");
maxidx = max(A(:))+1;
figure()
hold on;
plot(map(1:maxidx,1),'r')
plot(map(1:maxidx,2),'g')
plot(map(1:maxidx,3),'b')
hold off
Can someone explain the use of "maxidx = max(A(:))+1;" in this code .
Like what did the above code do?
Is there any syntax to do the above function?
채택된 답변
Stephen23
2021년 11월 8일
편집: Stephen23
2021년 11월 8일
"Can someone explain the use of "maxidx = max(A(:))+1;" in this code"
The answer can be derived from https://www.mathworks.com/help/matlab/creating_plots/image-types.html
The image file contains an indexed image, stored using integer indices:
class(imread("spine.tif"))
imfinfo("spine.tif")
"Like what did the above code do?"
Converts the maximum index of a integer indexed image (i.e. zero-based) into a MATLAB index (i.e. one-based).
"Is there any syntax to do the above function?"
What function?
댓글 수: 3
Stephen23
2021년 11월 9일
" Is there any other way or alternate solution to show the colormap functions of all color channels with the corresponding color"
[A,map] = imread("spine.tif");
mx = 1+max(A(:));
rgbplot(map(1:mx,:))
Compared against the original approach:
figure()
hold on;
plot(map(1:mx,1),'r')
plot(map(1:mx,2),'g')
plot(map(1:mx,3),'b')
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Blue에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!