Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
992a09a
Update questions.md
ftorres11 Feb 18, 2016
cdd586e
Merge pull request #1 from diego0020/master
ftorres11 Feb 18, 2016
344ba2f
Merge pull request #2 from diego0020/master
ftorres11 Feb 25, 2016
b3a5fdf
Added files via upload
ftorres11 Mar 3, 2016
e8d3687
Added files via upload
ftorres11 Mar 3, 2016
808f7f4
Update TorresF_LabHyb.m
ftorres11 Mar 3, 2016
4b1bfef
Added files via upload
ftorres11 Mar 3, 2016
d844d54
Merge pull request #3 from diego0020/master
ftorres11 Mar 3, 2016
63a6df7
Added files via upload
ftorres11 Mar 10, 2016
39aad7f
Merge pull request #4 from diego0020/master
ftorres11 Mar 10, 2016
34bc0ca
Update segment_by_clustering.m
ftorres11 Mar 14, 2016
cf2a3ce
Merge pull request #5 from diego0020/master
ftorres11 Mar 17, 2016
1553906
Merge pull request #6 from diego0020/master
ftorres11 Mar 26, 2016
15975b2
Added files via upload
ftorres11 Mar 27, 2016
acf05d5
Update DicoCreation.m
ftorres11 Mar 27, 2016
755aa6b
Delete DicoCreation.m
ftorres11 Mar 29, 2016
9985d67
Added files via upload
ftorres11 Mar 29, 2016
50b5091
Added files via upload
ftorres11 Mar 29, 2016
f6a0219
Added files via upload
ftorres11 Mar 30, 2016
689d586
Added files via upload
ftorres11 Mar 31, 2016
2513e8c
Merge pull request #7 from diego0020/master
ftorres11 Mar 31, 2016
6897ee7
Added files via upload
ftorres11 Apr 7, 2016
6824f5b
Delete phow_101Torres.m
ftorres11 Apr 7, 2016
ea6f4c4
Delete PHOW_Torres.m
ftorres11 Apr 7, 2016
c1dbaa2
Added files via upload
ftorres11 Apr 7, 2016
5aa69ef
Merge pull request #8 from diego0020/master
ftorres11 Apr 7, 2016
d49f1e5
Merge pull request #9 from diego0020/master
ftorres11 Apr 14, 2016
c7c1c04
Merge pull request #10 from diego0020/master
ftorres11 Feb 23, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 18 additions & 15 deletions lab01_git/questions.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
# Warmup Questions

1. What is the clone url of this repository?
> answer
> https://github.com/diego0020/lab_vision

2. What is the output of the ``cal`` command?

multi
line
answer
-1 Displays a month
+ -3 Displays previous/actual/Next Month
+ -m Shows monday as first week's day
+ -j Days sorted and numerated from January 1st
+ -y Current year's calendar.

# Homework Questions

1. What is the ``grep``command?
> answer
> It means "Global regular expression print" it looks for a pattern of text inside a file.

2. What is a *makefile*?
> answer
> A command that helps to compile programs. It recompiles files that are attached to the file that is being worked on.

4. What does the ``-prune`` option of ``find`` do? Give an example
> answer
> -prune in find command ignores directories and files that do not contain the item being searched for.
+ i.e. : find / -name Test.txt -prune

5. Where is the ``grub.cfg`` file
> answer
Expand All @@ -30,25 +33,25 @@
> answer

8. What does the ``cut`` command do?
> answer
> Extracts/cuts txt characters from a .txt file

9. What does the ``wget`` command do?
> answer
> It downloads archives/applications from the http listed after wget

9. What does the ``rsync`` command do?
> answer
> Copies and/or synchronizes files and directories remotely and locally in the system

10. What does the ``diff`` command do?
> answer
> Looks for differences in two files and/or the previous versions of a file.

10. What does the ``tail`` command do?
> answer
> Shows the last 10 lines modified in a file.

10. What does the ``tail -f`` command do?
> answer
> Shows the last 10 lines modified on a file and keeps track on them

10. What does the ``link`` command do?
> answer
> Binds together two files in a new file containing information about said files, should one file be modified, it will apply to the other file too.

11. How many users exist in the course server?
> answer
Expand All @@ -64,7 +67,7 @@
Save this script as ``find_duplicates.sh`` in this directory and commit your changes to github

16. What is the meaning of ``#! /bin/bash`` at the start of scripts?
> answer
> "#! /bin/bash Specifies which program to use to run said script, #(Sharp) !(Bin)

17. How many unique images are in the ``sipi_images`` database?
> answer
Expand Down
Binary file added lab3_hybrid/Boot.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added lab3_hybrid/Bottle.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions lab3_hybrid/Image_Description.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Boot Image

The Boot Image was taken from myself in the very same classroom in which we take the course
"Computer Vision", the idea of taking a picture of my very own boot was due to the fact that I
tried before implementing the code with my own face and a coin, yet I had no good results.
This boot has been with me for about a year now, and all I can say about it, is that it is a very
good piece of leatherwork and also it is a reliable foot wear.

Bottle Image

As soon as I took the picture of my boot, I thought about it's shape, I needed to have an item
with about the same proportions of said piece, and so as I was going home I realised how much
water I needed to drink due to the flue that I currently have, and so as I took up my bottle and
drank a little bit of water I realised that the bottle had about the same size and shape of my
boot, and so as I arrived home, I took my bottle out and had a picture of it.
This bottle is a sturdy one even if it is made of plastic, it has been with me for one and a half
years.
Binary file added lab3_hybrid/Pyramid.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 46 additions & 0 deletions lab3_hybrid/TorresF_LabHyb.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
clc, clear all, close all
%% Begining, reading the images
%For the Boot
Boot = imread('https://www.dropbox.com/s/snulaqkfod3shmu/Boot.jpg?dl=1');
Boot = rgb2gray(imresize(Boot,[256,256]));
%For the Bottle
Bottle = imread('https://www.dropbox.com/s/jp4trcppem35o6m/Bottle.jpg?dl=1');
Bottle = rgb2gray(imresize(Bottle,[256,256]));

%% Creation of the filters.
Gss = fspecial('gaussian',[45 45],4);
Gss2 = fspecial('gaussian',[30,30],8);

%% Filtering of the images
Low = imfilter(Bottle,Gss2);
Hi = Boot-imfilter(Boot,Gss);

Hyb = Low-Hi;
figure
imshow(Hyb),
title('Hybrid image between the bottle and the boot');

pause

%% Creation of the Piramid

Vec = [256,200,175,150,125,100,75,50,25];
Ims = im2uint8(zeros([256,256,3,length(Vec)]));
for x = 1:length(Vec)
Im = imresize(Hyb,[Vec(x) Vec(x)]);
Im = imresize(Im,[256 256]);
Im = repmat(Im,1,1,3);
Ims(:,:,:,x) = Im;
end

figure
montage(Ims);
title('Image Pyramid');

%Storing the Pyramid
im = getimage(gca);
imwrite(im,'Pyramid.png');




123 changes: 123 additions & 0 deletions lab4_segmentation/segment_by_clustering.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
function Out = segment_by_clustering(rgb_image,feature_space,...
clustering_method,number_of_clusters)
% FUNCTION SEGMENT_BY_ClUSTERING
% OUT = SEGMENT_BY_CLUSTERING(RGB_IMAGE,FEATURE_SPACE,...
% CLUSTERING_METHOD,NUMBER_OF_CLUSTERS)
% RGB_IMAGE. Rgb_image is the input image, it represents what you
% would want to segment.
% FEATURE_SPACE.Feature_Space sets the space of representation for the
% segmentation, it can either be RGB,L*AB,HSV; as well RGB+XY,L*AB+XY
% and HSV+XY. XY means that the input will be considering X and Y
% distances in the image, meaning localization.
% ClUSTERING_METHOD. Clustering method adjusts the way the clusters
% will be selected. It can either be 'K-Means','GMM','Watershed'. If
% watershed is selected, the number of clusters selecetd as an input
% will need to be a value from the range [0,255].
% NUMBER_OF_CLUSTERS. Number of Clusters adjusts the 'K' for each
% clustering method that requires it, if no argument for
% Number_of_clusters is input, the default will be 3.
% You may want to set the dynamic range of the image in imshow as [].
% Then I highly suggest you to use colormap(colorcube) to see the
% output.
% Felipe Torres F. Universidad de los Andes

%% Initialization
%Check for input variables
if(nargin<4)
number_of_clusters = 3;
end
if(nargin<3)
clustering_method = 'k-means';
end
if(nargin<2)
feature_space = 'rgb';
end

%Assigning the image to the right data type (optimal for k-means and GMM)
rgb_image = im2double(rgb_image);
[sr,sc,N] = size(rgb_image);
%% Check for input names of variables.
%Feature_Space
if(strcmpi(feature_space,'rgb')==1)
Im = rgb_image;
elseif(strcmpi(feature_space,'lab')==1)
Im = rgb2lab(rgb_image);
elseif(strcmpi(feature_space,'hsv')==1)
Im = rgb2hsv(rgb_image);
elseif(strcmpi(feature_space,'rgb+xy')==1)
Im = zeros([sr,sc,N+2]);
%Assignation of the distance coordinates.
Im(:,:,1:3) = rgb_image;
[F,C] = meshgrid(1:sr,1:sc);
Im(:,:,4) = C'/sc;Im(:,:,5) = F'/sr;
elseif(strcmpi(feature_space,'lab+xy')==1)
Im = zeros([sr,sc,N+2]);
Im(:,:,1:3) = rgb2lab(rgb_image);
%Assignation of the distance coordinates.
[F,C] = meshgrid(1:sr,1:sc);
Im(:,:,4) = C'/sc;Im(:,:,5) = F'/sr;
elseif(strcmpi(feature_space,'hsv+xy')==1)
Im = zeros([sr,sc,N+2]);
Im(:,:,1:3) = rgb2hsv(rgb_image);
%Assignation of the distance coordinates.
[F,C] = meshgrid(1:sr,1:sc);
Im(:,:,4) = C'/sc;Im(:,:,5) = F'/sr;
else
msg = strcat('The feature space must be either: rgb, lab, hsv,',...
{' '},'rgb+xy, lab+xy or hsv+xy');
error(char(msg));
end

%Clustering method
if(strcmpi(clustering_method,'K-MEANS')==1)
%Check for image size.
[~,~,z] = size(Im);
%Creation of the N-Dimensional array.
Vk = zeros(numel(Im(:,:,1)),z);
for x = 1:z
chn = Im(:,:,x);
Vk(:,x) = chn(:);
end
%Application of K-means.
[lbl,cent] = kmeans(Vk,number_of_clusters);
[~,I] = size(cent);
%Assigning centroids to values.
Vec = cent(lbl,round(I/2));
%Reshaping to get the clustered Image.
Out = reshape(Vec,[sr,sc]);

elseif(strcmpi(clustering_method,'GMM')==1)
[~,~,z] = size(Im);
%Creation of the N-Dimensional Vector.
Vk = zeros(numel(Im(:,:,1)),z);
for x = 1:z
chn = Im(:,:,x);
Vk(:,x) = chn(:);
end
%Creation of the GMM model.
GM = fitgmdist(Vk,number_of_clusters);
%Finding the values for each cluster.
idx = cluster(GM,Vk);
%Reshaping to get the clustered Image.
Out = reshape(idx,[sr,sc]);

elseif(strcmpi(clustering_method,'WATERSHED')==1)
h = number_of_clusters;
Im2 = Im(:,:,1:3);
Im2 = im2uint8(rgb2gray(Im2));
str = strel('disk',1);
dil = imdilate(Im2,str);
ero = imerode(Im2,str);
grad = dil-ero;
marker = imextendedmin(grad, h);
new_grad = imimposemin(grad, marker);
ws = watershed(new_grad);
Out = (ws);
else
%Error message to be displayed if the clustering methods does not exist
%in the parameters.
msg2 = strcat('Clustering method must be either K-Means,GMM or'...
,{' '},'Watersed');
error(char(msg2))
end
end
40 changes: 40 additions & 0 deletions lab6_textons/Assign_THist.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
function OutStruct = Assign_THist(Struct,k)
%Function ASSIGN TEXTON MAP & HISTOGRAM OUTSTRUCT = ASSIGN_TMAP(STRUCT,
% FBANK,K,assign)
% Function that Assigns to each
% and every single image of the
% images contained in structure
% STRUCT the texton map obtained
% with the Texton Dictionary.
% Struct. The ingresed Structure
% must contain fields: 'name',
% 'image', 'map', 'textons'.
% Otherwise an error will be
% K. K used to implement K-Means
% in the construction of the
% Dictionary. Default K = 50.

%% Check for input variables
%Check for K.
if(nargin<2)
k = 50;
end

%% Running the body of the function
addpath('lib');
%Check for the length of the structure
Lg = length(Struct);
try
for x = 1:Lg
%Recovering the Texton Map
Tmap = Struct(x).map;
%Assigning the Histogram
Struct(x).Hist = histc(Tmap(:),1:k)/numel(Tmap);
end
catch
er = strcat('Input arguments not correct, perhaps the Structure does',...
{' '},'have the required field "map"');
error(char(er))
end
OutStruct = Struct;
end
70 changes: 70 additions & 0 deletions lab6_textons/DicoCreation_Test.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
clc, clear all, close all
%% Initiation
%Addition of the path
addpath('lib')
%Route to train directory
dTrain = fullfile(cd,'test');
%Creation of structure containing the names of the cathegories
nomCat = {'bark1','bark2','bark3','wood1','wood2','wood3',...
'water','granite','marble','floor1','floor2','pebbles',...
'wall','brick1','brick2','glass1','glass2','carpet1',...
'carpet2','upholstery','wallpaper','fur','knit','corduory',...
'plaid'};
%Cathegory-wise codes
indCat = {'T01','T02','T03','T04','T05','T06','T07','T08','T09','T10',...
'T11','T12','T13','T14','T15','T16','T17','T18','T19','T20','T21','T22',...
'T23','T24','T25'};

%Creation of Structure containing the suffixes for each image in each
%cathegory
for x = 30:40
if x <10
nomPerm{x} = strcat('_0',num2str(x),'.jpg');
else
nomPerm{x} = strcat('_',num2str(x),'.jpg');
end
end

%Filter Bank creation
[fb] = fbCreate;
%Number of textons in the dictionary
k = 50;

%Creation of Texton Dictionary Structure
TXT=struct('name',[],'image',[],'map',[],'textons',[]);
%% Preparation before passing the for to assign textons for ten images per
%cathegory
inds = 1:10:260;
cats = 1:25;
%Aleatorization of the system
vec = 31:40;
VEC = repmat(vec,1,100);
%For assigning the textons and creating the texton dictionary per
%cathegory, each cathegory has 10 sample images
for x = 1:250
for y = 2:length(inds)
if x>=inds(y-1)&&x<inds(y)
%Assigning the name
TXT(x).name = char(nomCat(cats(y-1)));
nam = char(indCat(cats(y-1)));
%Assigning the image cathegory to the correct image code
imnom = strcat(nam,char(nomPerm(VEC(x))));
im = im2double(imread(fullfile(dTrain,imnom)));
TXT(x).image = im;
%Computation of textons
[map,textons] = computeTextons(fbRun(fb,im),k);
TXT(x).map = map;
TXT(x).textons = textons;
disp(strcat('Succesfully created Textons dictionary for image'...
,{' '},imnom));
end
end
end
save('TextureDico_Test.mat','TXT');







Loading