Você está na página 1de 1

function [ out ] = blacknwhite( inp,color )

%UNTITLED3 Summary of this function goes here


% Detailed explanation goes here
% inp(:,:,1)=(250/max(max(inp(:,:,1))))*inp(:,:,1);
% inp(:,:,2)=(250/max(max(inp(:,:,2))))*inp(:,:,2);
% inp(:,:,3)=(250/max(max(inp(:,:,3))))*inp(:,:,3);
a=max(max(inp(:,:,1)));
b=max(max(inp(:,:,2)));
c=max(max(inp(:,:,3)));
d=min(a,b);
inp=(250/min(d,c))*inp;
switch color
case 1
sel=1;
oth1=2;
oth2=3;
case 2
sel=2;
oth1=1;
oth2=3;
case 3
sel=3;
oth1=2;
oth2=1;
otherwise
disp('please mention color RGB only');
return
end
% inp(:,:,sel)=inp(:,:,sel);
% inp(:,:,oth1)=0*inp(:,:,oth1);
% inp(:,:,oth2)=0*inp(:,:,oth2);
% inp=rgb2gray(inp);
sz=size(inp);
% threshold=min(max(inp))
% if(threshold<1)
%
inp=inp*100/threshold;
% %
threshold=max(max(inp))
% end
% if(threshold<10)
%
inp=inp*10;
% %
threshold=max(max(inp))
% end
out=inp(:,:,1);
for i=1:sz(1)
for j=1:sz(2)
if(inp(i,j,sel)>=(inp(i,j,oth1)+20))&&(inp(i,j,sel)>=(inp(i,j,oth2)+20))
out(i,j)=1;
if((inp(i,j,oth1)>230)||(inp(i,j,oth2)>230))
out(i,j)=0;
end
else
out(i,j)=0;
end
%
if(i==1)
%
inp(i,j)=1;
%
end
end
end

Você também pode gostar