For loop each RGB image channel
Show older comments
I want to make this manual saperated RGB channel code into for loop, each channel will undergo the same calculation. Can anybody help me how to convert it into for loop code?
here the image: 

t = imread ('luekemia.png')
%% black & white
bw = imbinarize (t,0.4);
bw = ~bw;
%% remove noise
bw2 = bwareaopen (bw,100);
%%separate 3 layer RGB
R = t(:,:,1);
G = t(:,:,2);
B = t(:,:,3);
R(bw2(:)==0) = 255;
G(bw2(:)==0) = 255;
B(bw2(:)==0) = 255;
c = cat(3,R,G,B);
%calculate range R
rmax = max(R(bw2(:)~=0))
rmin = min(R(bw2(:)~=0))
gmax = max(G(bw2(:)~=0))
gmin = min(G(bw2(:)~=0))
bmax = max(B(bw2(:)~=0))
bmin = min(B(bw2(:)~=0))
Accepted Answer
More Answers (1)
Image Analyst
on 8 Nov 2021
0 votes
Not sure what analysis you want to do (you didn't say what the "calculations" were) but I just thought I'd point you to a similar example by the Mathworks:
Categories
Find more on Images in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!