Skip to content

Instantly share code, notes, and snippets.

@ozgurgulsuna
Created August 12, 2022 16:37
Show Gist options
  • Save ozgurgulsuna/d6bd0f288a831a497eea239cc878f2a0 to your computer and use it in GitHub Desktop.
Save ozgurgulsuna/d6bd0f288a831a497eea239cc878f2a0 to your computer and use it in GitHub Desktop.
%%
clc
clear all
%%
a = imread('C:\Users\ozgur\Desktop\sxs.jpg');
imshow(a);
[RGBdata, map, alpha] = imread('C:\Users\ozgur\Desktop\sxs.jpg', 'jpg');
%% Filter out white
for i =1: length(a(:,1,1))
for j=1: length(a(1,:,1))
if a(i,j,1)>230 && a(i,j,2)>230 && a(i,j,1)>230
a(i,j,1)=0;
a(i,j,2)=0;
a(i,j,3)=255;
end
end
end
imshow(a);
%%
hsv = rgb2hsv(a);
imshow(hsv);
%%
hsv(500,500,:);
gray_hsv=zeros([1027,1600,3]);
%%
for i =1: length(hsv(:,1,1))
for j=1: length(hsv(1,:,1))
gray_hsv(i,j,1)=1-(hsv(i,j,1)*360/240);
gray_hsv(i,j,2)=1-(hsv(i,j,1)*360/240);
gray_hsv(i,j,3)=1-(hsv(i,j,1)*360/240);
end
end
%%
imshow(gray_hsv);
imwrite(gray_hsv, 'C:\Users\ozgur\Desktop\color22.png', 'png', 'Alpha', alpha )
%%
a= [hsv(:,:,1);hsv(:,:,1);hsv(:,:,1)];
%%
gray=rgb2gray(gray_hsv);
imshow(gray);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment