Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Help me complete or fix this code so I get around 2 5 0 0 pixels in the attached image with Matlab: I = imread

Help me complete or fix this code so I get around 2500 pixels in the attached image with Matlab:
I = imread("MnMs.tif");
I = im2double(I);
% Apply median filter
CI_med = I;
for Layer =1:3
CI_med(:,:,Layer)= medfilt2(CI_med(:,:,Layer),[33]);
end
% Apply max filter to the median filtered image
CI = CI_med;
for Layer =1:3
CI(:,:,Layer)= ordfilt2(CI(:,:,Layer),9, ones(3,3));
end
R = CI(:,:,1);
G = CI(:,:,2);
B = CI(:,:,3);
% Initialize color matrices
Wh = zeros(512); % White
Re = zeros(512); % Red
Gr = zeros(512); % Green
Bl = zeros(512); % Blue
Gy = zeros(512); % Gray
Pi = zeros(512); % Pink
Pu = zeros(512); % Purple
Ol = zeros(512); % Olive
Br = zeros(512); % Brown
BB = zeros(512); % Background
missing = zeros(512); % Missing
% Adjust thresholds and conditions
for m =1:512
for n =1:512
miss =0;
if (R(n,m)>0.95) && (G(n,m)>0.95) && (B(n,m)>0.95)
Wh(n,m)=1;
miss =1;
end
if (R(n,m)>0.95) && (G(n,m)0.5) && (B(n,m)0.5)
Re(n,m)=1;
miss =1;
end
if (R(n,m)0.5) && (G(n,m)>0.95) && (B(n,m)0.5)
Gr(n,m)=1;
miss =1;
end
if (R(n,m)0.5) && (G(n,m)0.5) && (B(n,m)>0.95)
Bl(n,m)=1;
miss =1;
end
if (R(n,m)>0.1) && (G(n,m)0.3)
Gy(n,m)=1;
miss =1;
end
if (R(n,m)>0.7) && (G(n,m)0.3) && (B(n,m)>0.5)
Pi(n,m)=1;
miss =1;
end
if (R(n,m)>0.3) && (R(n,m)0.5)
Pu(n,m)=1;
miss =1;
end
if (R(n,m)>0.5) && (R(n,m)0.7)
Ol(n,m)=1;
miss =1;
end
if (G(n,m)>0.5) && (G(n,m)0.7)
Br(n,m)=1;
miss =1;
end
if (R(n,m)0.1) && (G(n,m)0.2) && (B(n,m)0.1)
BB(n,m)=1;
miss =1;
end
if (miss ==0)
missing(n,m)=1;
end
end
end
% Display the results
figure(2)
subplot(3,4,1); imshow(I); title(['Original image: ', num2str(512*512)]);
subplot(3,4,2); imshow(Wh,[]); title(['White: ', num2str(sum(sum(Wh)))]);
subplot(3,4,3); imshow(Re,[]); title(['Red: ', num2str(sum(sum(Re)))]);
subplot(3,4,4); imshow(Gr,[]); title(['Green: ', num2str(sum(sum(Gr)))]);
subplot(3,4,5); imshow(Bl,[]); title(['Blue: ', num2str(sum(sum(Bl)))]);
subplot(3,4,6); imshow(Gy,[]); title(['Gray: ', num2str(sum(sum(Gy)))]);
subplot(3,4,7); imshow(Pi,[]); title(['Pink: ', num2str(sum(sum(Pi)))]);
subplot(3,4,8); imshow(Pu,[]); title(['Purple: ', num2str(sum(sum(Pu)))]);
subplot(3,4,9); imshow(Ol,[]); title(['Olive: ', num2str(sum(sum(Ol)))]);
subplot(3,4,10); imshow(Br,[]); title(['Brown: ', num2str(sum(sum(Br)))]);
subplot(3,4,11); imshow(BB,[]); title(['Background: ', num2str(sum(sum(BB)))]);
subplot(3,4,12); imshow(missing,[]); title(['Missing: ', num2str(sum(sum(missing)))]);
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Systems

Authors: Sham Navathe,Ramez Elmasri

5th Edition

B01FGJTE0Q, 978-0805317558

More Books

Students also viewed these Databases questions

Question

=+ (a) Prove that I()(t)= fox'-1(log x)*e * dx.

Answered: 1 week ago