├── README.md ├── Medium-ActiveContours ├── IntelligentScissors.cpp ├── main.cpp ├── IntelligentScissors.h ├── Makefile └── readme.md ├── Easy-Reconstruction ├── main.cpp ├── Reconstruction.cpp ├── Reconstruction.h ├── Makefile └── readme.md ├── Easy-MNISTClassifier ├── main.cpp ├── MNISTClassifier.cpp ├── MNISTClassifier.h ├── Makefile └── readme.md ├── LICENSE └── .gitignore /README.md: -------------------------------------------------------------------------------- 1 | # ExercisesCollection 2 | A collection of coding exercises, mostly in computer vision and graphics. 3 | 4 | Please clone the repo and work through the exercises at will. 5 | Only create pull requests that are related to the exercise, please do not create PRs with answers. 6 | 7 | Thank you! 8 | -------------------------------------------------------------------------------- /Medium-ActiveContours/IntelligentScissors.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * IntelligentScissors.cpp 3 | * 4 | * Created on: Oct 6, 2016 5 | * Author: roy_shilkrot 6 | */ 7 | 8 | #include "IntelligentScissors.h" 9 | 10 | IntelligentScissors::IntelligentScissors(const cv::Mat& input) { 11 | } 12 | 13 | IntelligentScissors::~IntelligentScissors() { 14 | } 15 | 16 | void IntelligentScissors::segment() { 17 | } 18 | 19 | void IntelligentScissors::preprocess() { 20 | } 21 | -------------------------------------------------------------------------------- /Medium-ActiveContours/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * main.cpp 3 | * 4 | * Created on: Oct 6, 2016 5 | * Author: roy_shilkrot 6 | */ 7 | 8 | #include "IntelligentScissors.h" 9 | 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | using namespace cv; 15 | 16 | int main(int argc, char** argv) { 17 | Mat image = imread("input.jpg"); 18 | 19 | IntelligentScissors segmenter(image); 20 | segmenter.segment(); 21 | } 22 | 23 | -------------------------------------------------------------------------------- /Easy-Reconstruction/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * main.cpp 3 | * 4 | * Created on: Oct 17, 2016 5 | * Author: roy_shilkrot 6 | */ 7 | 8 | #include "Reconstruction.h" 9 | 10 | #include 11 | #include 12 | 13 | using namespace std; 14 | using namespace cv; 15 | 16 | int main(int argc, char** argv) { 17 | Mat imageLeft = imread("input-left.jpg"); 18 | Mat imageRight = imread("input-right.jpg"); 19 | 20 | Reconstruction reconstruction(imageLeft, imageRight); 21 | reconstruction.reconstruct(); 22 | } 23 | 24 | -------------------------------------------------------------------------------- /Easy-Reconstruction/Reconstruction.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Reconstruction.cpp 3 | * 4 | * Created on: Oct 17, 2016 5 | * Author: roy_shilkrot 6 | */ 7 | 8 | #include "Reconstruction.h" 9 | 10 | Reconstruction::Reconstruction(const cv::Mat& inputLeft, 11 | const cv::Mat& inputRight) { 12 | } 13 | 14 | Reconstruction::~Reconstruction() { 15 | } 16 | 17 | void Reconstruction::reconstruct() { 18 | //Hint: extract 2D features, match, recover camera poses, prune features, triangulate 2D features matching to 3D points. 19 | } 20 | 21 | void Reconstruction::saveResultToFile(const std::string& filename) { 22 | } 23 | -------------------------------------------------------------------------------- /Easy-MNISTClassifier/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * main.cpp 3 | * 4 | * Created on: Aug 30, 2016 5 | * Author: roy_shilkrot 6 | */ 7 | 8 | #include "MNISTClassifier.h" 9 | 10 | #include 11 | 12 | using namespace std; 13 | 14 | int main(int argc, char** argv) { 15 | MNISTDataset trainDataset = MNISTClassifier::loadDatasetFromFiles("train-labels-idx1-ubyte", "train-images-idx3-ubyte"); 16 | MNISTDataset testDataset = MNISTClassifier::loadDatasetFromFiles("t10k-labels-idx1-ubyte", "t10k-images-idx3-ubyte"); 17 | 18 | MNISTClassifier classifier(trainDataset); 19 | classifier.runTestDatasetAndPrintStats(testDataset); 20 | } 21 | -------------------------------------------------------------------------------- /Easy-Reconstruction/Reconstruction.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Reconstruction.h 3 | * 4 | * Created on: Oct 17, 2016 5 | * Author: roy_shilkrot 6 | */ 7 | 8 | #ifndef RECONSTRUCTION_H_ 9 | #define RECONSTRUCTION_H_ 10 | 11 | #include 12 | 13 | class Reconstruction { 14 | public: 15 | Reconstruction(const cv::Mat& inputLeft, const cv::Mat& inputRight); 16 | virtual ~Reconstruction(); 17 | 18 | /** 19 | * Reconstruct the scene from the two views. 20 | */ 21 | void reconstruct(); 22 | 23 | /** 24 | * Save the reconstruction result to an XYZ file. 25 | * @param filename the filename to save into (overwrite). 26 | */ 27 | void saveResultToFile(const std::string& filename); 28 | }; 29 | 30 | #endif /* RECONSTRUCTION_H_ */ 31 | -------------------------------------------------------------------------------- /Easy-MNISTClassifier/MNISTClassifier.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * MNISTClassifier.cpp 3 | * 4 | * Created on: Aug 30, 2016 5 | * Author: roy_shilkrot 6 | */ 7 | 8 | #include "MNISTClassifier.h" 9 | 10 | 11 | MNISTClassifier::MNISTClassifier(const MNISTDataset& trainDataset) { 12 | // TODO Auto-generated stub, complete 13 | } 14 | 15 | MNISTClassifier::~MNISTClassifier() { 16 | // TODO Auto-generated stub, complete 17 | } 18 | 19 | int MNISTClassifier::classifyImage(const cv::Mat& sample) { 20 | // TODO Auto-generated stub, copmlete 21 | 22 | return -1; 23 | } 24 | 25 | MNISTDataset MNISTClassifier::loadDatasetFromFiles( 26 | const std::string& labelsFile, const std::string& imagesFile) { 27 | // TODO Auto-generated stub, complete 28 | 29 | return {}; 30 | } 31 | 32 | void MNISTClassifier::runTestDatasetAndPrintStats( 33 | const MNISTDataset& inputDataset) { 34 | // TODO Auto-generated stub, complete 35 | } 36 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Roy Shilkrot 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files 2 | *.slo 3 | *.lo 4 | *.o 5 | *.obj 6 | 7 | # Precompiled Headers 8 | *.gch 9 | *.pch 10 | 11 | # Compiled Dynamic libraries 12 | *.so 13 | *.dylib 14 | *.dll 15 | 16 | # Fortran module files 17 | *.mod 18 | *.smod 19 | 20 | # Compiled Static libraries 21 | *.lai 22 | *.la 23 | *.a 24 | *.lib 25 | 26 | # Executables 27 | *.exe 28 | *.out 29 | *.app 30 | 31 | *.DS_Store 32 | .AppleDouble 33 | .LSOverride 34 | 35 | # Icon must end with two \r 36 | Icon 37 | 38 | 39 | # Thumbnails 40 | ._* 41 | 42 | # Files that might appear in the root of a volume 43 | .DocumentRevisions-V100 44 | .fseventsd 45 | .Spotlight-V100 46 | .TemporaryItems 47 | .Trashes 48 | .VolumeIcon.icns 49 | .com.apple.timemachine.donotpresent 50 | 51 | # Directories potentially created on remote AFP share 52 | .AppleDB 53 | .AppleDesktop 54 | Network Trash Folder 55 | Temporary Items 56 | .apdisk 57 | 58 | # Windows image file caches 59 | Thumbs.db 60 | ehthumbs.db 61 | 62 | # Folder config file 63 | Desktop.ini 64 | 65 | # Recycle Bin used on file shares 66 | $RECYCLE.BIN/ 67 | 68 | # Windows Installer files 69 | *.cab 70 | *.msi 71 | *.msm 72 | *.msp 73 | 74 | # Windows shortcuts 75 | *.lnk 76 | -------------------------------------------------------------------------------- /Medium-ActiveContours/IntelligentScissors.h: -------------------------------------------------------------------------------- 1 | /* 2 | * IntelligentScissors.h 3 | * 4 | * Created on: Oct 6, 2016 5 | * Author: roy_shilkrot 6 | * 7 | * This is an exercise implementation of "Intelligent Scissors": 8 | * Eric N. Mortensen and William A. Barrett. 1995. Intelligent scissors for image composition. 9 | * In Proceedings of the 22nd annual conference on Computer graphics and interactive techniques (SIGGRAPH '95) 10 | * 11 | */ 12 | 13 | #ifndef INTELLIGENTSCISSORS_H_ 14 | #define INTELLIGENTSCISSORS_H_ 15 | 16 | #include 17 | 18 | class IntelligentScissors { 19 | public: 20 | IntelligentScissors(const cv::Mat& input); 21 | virtual ~IntelligentScissors(); 22 | 23 | /** 24 | * Segment the object from the background. 25 | * Optionally, make this an interactive function that displays a UI for the user to make markings on the image. 26 | * Otherwise, this function will need a set of seed points as a parameter (e.g. `const vector& seeds`) 27 | */ 28 | void segment(); 29 | 30 | private: 31 | /** 32 | * Preprocess the input image to prepare for interaction. 33 | * Hint: Calculate the zero-crossings map, gradient magnitudes and gradient directions. 34 | */ 35 | void preprocess(); 36 | }; 37 | 38 | #endif /* INTELLIGENTSCISSORS_H_ */ 39 | -------------------------------------------------------------------------------- /Easy-MNISTClassifier/MNISTClassifier.h: -------------------------------------------------------------------------------- 1 | /* 2 | * MNISTClassifier.h 3 | * 4 | * Created on: Aug 30, 2016 5 | * Author: roy_shilkrot 6 | */ 7 | 8 | #ifndef MNISTCLASSIFIER_H_ 9 | #define MNISTCLASSIFIER_H_ 10 | 11 | #include 12 | 13 | #include 14 | 15 | struct MNISTDataset { 16 | //TODO: add data fields as nessecary 17 | //e.g. std::vector images; 18 | // std::vector labels; 19 | }; 20 | 21 | class MNISTClassifier { 22 | public: 23 | MNISTClassifier(const MNISTDataset& trainDataset); 24 | virtual ~MNISTClassifier(); 25 | 26 | /** 27 | * Classify a single sample image. 28 | * 29 | * @param sample The sample to classify. 30 | * @returns A class ID. 31 | */ 32 | int classifyImage(const cv::Mat& sample); 33 | 34 | /** 35 | * Run the classifier over the test dataset and print out relevant statistics. 36 | */ 37 | void runTestDatasetAndPrintStats(const MNISTDataset& inputDataset); 38 | 39 | /** 40 | * Load the MNIST dataset from the labels and images files, as described in the bottom of: 41 | * http://yann.lecun.com/exdb/mnist/ 42 | * 43 | * @param labelsFile The labels file. 44 | * @param imagesFile The images file. 45 | * @returns The MNIST dataset struct populated. 46 | */ 47 | static MNISTDataset loadDatasetFromFiles(const std::string& labelsFile, const std::string& imagesFile); 48 | 49 | private: 50 | //... add member variables here 51 | }; 52 | 53 | #endif /* MNISTCLASSIFIER_H_ */ 54 | -------------------------------------------------------------------------------- /Easy-MNISTClassifier/Makefile: -------------------------------------------------------------------------------- 1 | #Makefile 2 | # Created on: Aug 30, 2016 3 | # Author: roy_shilkrot 4 | # 5 | # Adapted from http://blog.toonormal.com/2013/05/11/barebones-useful-generic-makefile/ 6 | 7 | TARGET_FILE := MNISTClassifier 8 | SRC_FILES := MNISTClassifier.cpp main.cpp 9 | LIBRARY_FILES := -lopencv_core -lopencv_ml -lopencv_highgui -lopencv_imgproc 10 | SRC_FILE_TYPES := .c .cpp 11 | 12 | FLAGS := --std=c++11 13 | C_FLAGS := $(FLAGS) 14 | CPP_FLAGS := $(FLAGS) 15 | LD_FLAGS := 16 | CC := gcc 17 | CXX := g++ 18 | LD := $(CXX) 19 | 20 | 21 | OUTPUT_DIR := output/ 22 | OBJ_DIR := obj/ 23 | TARGET := $(OUTPUT_DIR)$(TARGET_FILE) 24 | O_FILES := $(addprefix $(OBJ_DIR),$(addsuffix .o,$(SRC_FILES))) 25 | O_DIRS := $(sort $(dir $(O_FILES))) 26 | 27 | # Link Command # 28 | $(TARGET): _makedirs $(O_FILES) 29 | $(LD) $(LD_FLAGS) $(O_FILES) $(LIBRARY_FILES) -o $@ 30 | 31 | # Compile Commands # 32 | $(OBJ_DIR)%.cpp.o: %.cpp 33 | $(CXX) -c $(DEFINES) $(INCLUDE_DIRS) $(CPP_FLAGS) $< -o $@ 34 | 35 | all: $(TARGET) 36 | 37 | _makedirs: 38 | mkdir -p $(O_DIRS) $(OUTPUT_DIR) 39 | 40 | clean: 41 | rm -fr $(OBJ_DIR) $(OUTPUT_DIR) 42 | 43 | info: 44 | @echo TARGET_FILE: $(TARGET_FILE) [$(TARGET)] 45 | @echo 46 | @echo SRC_FILES: $(SRC_FILES) 47 | @echo 48 | @echo O_FILES: $(O_FILES) 49 | @echo 50 | @echo O_DIRS: $(O_DIRS) 51 | 52 | .PHONY: _makedirs clean info 53 | -------------------------------------------------------------------------------- /Medium-ActiveContours/Makefile: -------------------------------------------------------------------------------- 1 | #Makefile 2 | # Created on: Aug 30, 2016 3 | # Author: roy_shilkrot 4 | # 5 | # Adapted from http://blog.toonormal.com/2013/05/11/barebones-useful-generic-makefile/ 6 | 7 | TARGET_FILE := IntelligentScissors 8 | SRC_FILES := IntelligentScissors.cpp main.cpp 9 | LIBRARY_FILES := -L/usr/local/lib -lopencv_core -lopencv_ml -lopencv_highgui -lopencv_imgproc 10 | SRC_FILE_TYPES := .c .cpp 11 | 12 | FLAGS := --std=c++11 -I/usr/local/include 13 | C_FLAGS := $(FLAGS) 14 | CPP_FLAGS := $(FLAGS) 15 | LD_FLAGS := 16 | CC := gcc 17 | CXX := g++ 18 | LD := $(CXX) 19 | 20 | 21 | OUTPUT_DIR := output/ 22 | OBJ_DIR := obj/ 23 | TARGET := $(OUTPUT_DIR)$(TARGET_FILE) 24 | O_FILES := $(addprefix $(OBJ_DIR),$(addsuffix .o,$(SRC_FILES))) 25 | O_DIRS := $(sort $(dir $(O_FILES))) 26 | 27 | # Link Command # 28 | $(TARGET): _makedirs $(O_FILES) 29 | $(LD) $(LD_FLAGS) $(O_FILES) $(LIBRARY_FILES) -o $@ 30 | 31 | # Compile Commands # 32 | $(OBJ_DIR)%.cpp.o: %.cpp 33 | $(CXX) -c $(DEFINES) $(INCLUDE_DIRS) $(CPP_FLAGS) $< -o $@ 34 | 35 | all: $(TARGET) 36 | 37 | _makedirs: 38 | mkdir -p $(O_DIRS) $(OUTPUT_DIR) 39 | 40 | clean: 41 | rm -fr $(OBJ_DIR) $(OUTPUT_DIR) 42 | 43 | info: 44 | @echo TARGET_FILE: $(TARGET_FILE) [$(TARGET)] 45 | @echo 46 | @echo SRC_FILES: $(SRC_FILES) 47 | @echo 48 | @echo O_FILES: $(O_FILES) 49 | @echo 50 | @echo O_DIRS: $(O_DIRS) 51 | 52 | .PHONY: _makedirs clean info 53 | -------------------------------------------------------------------------------- /Easy-Reconstruction/Makefile: -------------------------------------------------------------------------------- 1 | #Makefile 2 | # Created on: Aug 30, 2016 3 | # Author: roy_shilkrot 4 | # 5 | # Adapted from http://blog.toonormal.com/2013/05/11/barebones-useful-generic-makefile/ 6 | 7 | TARGET_FILE := Reconstruction 8 | SRC_FILES := Reconstruction.cpp main.cpp 9 | LIBRARY_FILES := -L/usr/local/lib -lopencv_core -lopencv_ml -lopencv_highgui -lopencv_imgcodecs -lopencv_imgproc -lopencv_calib3d -lopencv_features2d 10 | SRC_FILE_TYPES := .c .cpp 11 | 12 | FLAGS := --std=c++11 -I/usr/local/include 13 | C_FLAGS := $(FLAGS) 14 | CPP_FLAGS := $(FLAGS) 15 | LD_FLAGS := 16 | CC := gcc 17 | CXX := g++ 18 | LD := $(CXX) 19 | 20 | 21 | OUTPUT_DIR := output/ 22 | OBJ_DIR := obj/ 23 | TARGET := $(OUTPUT_DIR)$(TARGET_FILE) 24 | O_FILES := $(addprefix $(OBJ_DIR),$(addsuffix .o,$(SRC_FILES))) 25 | O_DIRS := $(sort $(dir $(O_FILES))) 26 | 27 | # Link Command # 28 | $(TARGET): _makedirs $(O_FILES) 29 | $(LD) $(LD_FLAGS) $(O_FILES) $(LIBRARY_FILES) -o $@ 30 | 31 | # Compile Commands # 32 | $(OBJ_DIR)%.cpp.o: %.cpp 33 | $(CXX) -c $(DEFINES) $(INCLUDE_DIRS) $(CPP_FLAGS) $< -o $@ 34 | 35 | all: $(TARGET) 36 | 37 | _makedirs: 38 | mkdir -p $(O_DIRS) $(OUTPUT_DIR) 39 | 40 | clean: 41 | rm -fr $(OBJ_DIR) $(OUTPUT_DIR) 42 | 43 | info: 44 | @echo TARGET_FILE: $(TARGET_FILE) [$(TARGET)] 45 | @echo 46 | @echo SRC_FILES: $(SRC_FILES) 47 | @echo 48 | @echo O_FILES: $(O_FILES) 49 | @echo 50 | @echo O_DIRS: $(O_DIRS) 51 | 52 | .PHONY: _makedirs clean info 53 | -------------------------------------------------------------------------------- /Easy-MNISTClassifier/readme.md: -------------------------------------------------------------------------------- 1 | # MNIST Classifier 2 | 3 | Download and extract the MNIST dataset: http://yann.lecun.com/exdb/mnist/ 4 | 5 | Your goal is to write a simple classifier over this canonical dataset. 6 | 7 | The classifier may be implemented using any machine learning construct at your disposal. 8 | However for a straight forward and simple implementation you may choose an SVM using all the pixels as the feature vector. 9 | 10 | This exercise uses OpenCV for an imaging and machine learning library, however you are free to replace it for something else at your discretion. 11 | 12 | ### Bonus points 13 | * Achieve sub 1% accuracy. 14 | * Integrate a non-trivial feature, e.g. shape descriptor. 15 | 16 | ### Files 17 | The files `MNISTClassifier.h` and `MNISTClassifier.cpp` are a barebones template for your work. 18 | Feel free to make any change to the API. 19 | 20 | The file `main.cpp` should be the entry point to your executable that performs some part of the classification work (build the classifier, run it over the test dataset, etc.) 21 | 22 | ### Coding styleguide 23 | Please write *clean and readable code*: 24 | * Use proper indentation, with spaces rather than tabs. 25 | * Always use curly brackets, for `if`s, `for`s, `while`s and everything else. No "orphan" statements, please. 26 | * Add spaces between operators, e.g. `a * b`. 27 | * Document methods and classes, both with inline comments and doxygen-esque documentation. 28 | * Use meaningful variable names. No single-character var names, please. 29 | * Split large functions to smaller, simpler chunks and [DRY](https://en.wikipedia.org/wiki/Don%27t_repeat_yourself). 30 | * Avoid deeply nested `if`s and `for`s. 31 | * Prefer C++11 features, e.g. using `and` over `&&`, smart `for`s: `for (int it : vector)`, using `auto`s, etc. 32 | * Do not leave code commented out. 33 | * Properly note the author and the date of file modification in the top of the source file. 34 | 35 | There is a standard `Makefile` for you to use for compiling. It assumes a Unix-like OS. -------------------------------------------------------------------------------- /Easy-Reconstruction/readme.md: -------------------------------------------------------------------------------- 1 | # 3D Reconstruction - Easy 2 | 3 | Your goal is to write a simple 3D reconstruction pipeline from a stereo view. 4 | 5 | Download (at least) two images from one of the Dense MVS datasets: http://cvlabwww.epfl.ch/data/multiview/denseMVS.html 6 | (e.g. the fountain dataset http://cvlabwww.epfl.ch/data/multiview/fountain_dense.html). Keep only the two images you would like to work on, and keep in mind the limits of stereo matching (if images are very far from each other there may be very little matching keypoints). 7 | 8 | Your task, should you choose to accept it, is to implement a sparse 3D reconstruction pipeline by extracting and matching 2D features in the two images. 9 | 10 | This exercise assumes OpenCV will be used for an imaging and machine learning library, however you are free to replace it for something else at your discretion. However, if you will be using OpenCV (3.x) the following functions should probably be used in the reconstruction process: 11 | 12 | * `findEssentialMat` 13 | * `recoverPose` 14 | * `triangulatePoints` 15 | * `projectPoints` 16 | * `undistortPoints` 17 | * `convertPointsFromHomogeneous` and `convertPointsToHomogeneous` 18 | 19 | For feature extarction just pick a standard detector, such as `ORB`. 20 | 21 | Output your result into a simple XYZ point cloud file (where every line is simply ` `). 22 | 23 | ### Bonus points 24 | * Implement a more dense reconstruction with Optical Flow. 25 | * Add more than 2 views to the reconstruction. 26 | * Output the results into XYZRGB file adding color from the images to the points, and also output the camera positions. 27 | 28 | ### Files 29 | The files `Reconstruction.h` and `Reconstruction.cpp` are a barebones template for your work. 30 | Feel free to make any change to the API. 31 | 32 | The file `main.cpp` should be the entry point to your executable that performs the reconstruction work. 33 | 34 | ### Coding styleguide 35 | Please write *clean and readable code*: 36 | * Use proper indentation, with spaces rather than tabs. 37 | * Always use curly brackets, for `if`s, `for`s, `while`s and everything else. No "orphan" statements, please. 38 | * Add spaces between operators, e.g. `a * b`. 39 | * Document methods and classes, both with inline comments and doxygen-esque documentation. 40 | * Use meaningful variable names. No single-character var names, please. 41 | * Split large functions to smaller, simpler chunks and [DRY](https://en.wikipedia.org/wiki/Don%27t_repeat_yourself). 42 | * Avoid deeply nested `if`s and `for`s. 43 | * Prefer C++11 features, e.g. using `and` over `&&`, smart `for`s: `for (int it : vector)`, using `auto`s, etc. 44 | * Do not leave code commented out. 45 | * Properly note the author and the date of file modification in the top of the source file. 46 | 47 | There is a standard `Makefile` for you to use for compiling. It assumes a Unix-like OS. 48 | -------------------------------------------------------------------------------- /Medium-ActiveContours/readme.md: -------------------------------------------------------------------------------- 1 | # Active Contours Segmenter - Moderate 2 | 3 | Your goal is to write a simple 2D active contours segmenter. 4 | Active Contours was suggested circa 1987 by Kass, Witkin and Terzopoulos [1], at the time called "Snakes". However since then many similar methods were suggested. One particularly interesting one, for it's simplicity, is the "Intelligent Scissors" by Mortensen and Barrett [2]. 5 | 6 | Your task, should you choose to accept it, is to implement the vanilla version of the Intelligent Scissors work. 7 | In [2] you are best to read the entirety of section 3, however reading just 3.1 and 3.2 should set you on a clear path for implementation (pay close attention to their provided algorithm). Sub-section 3.4 suggest a rudimentary UI for the segmenter, which you may want to implement too. 8 | 9 | This exercise assumes OpenCV will be used for an imaging and machine learning library, however you are free to replace it for something else at your discretion. 10 | 11 | For images to segment you can use the Berkley 500 segmentation dataset: https://www2.eecs.berkeley.edu/Research/Projects/CS/vision/grouping/resources.html 12 | 13 | ### Bonus points 14 | * Implement sub-section 3.4 form [2] to introduce "path cooling", which improves the interactivity of the tool. 15 | * Implement sub-section 3.5 from [2] to help with ambiguous edges. 16 | * Big bonus: Write your Intelligent Scissor tool as a plug-in for GIMP [3]. 17 | 18 | ### Files 19 | The files `IntelligentScissors.h` and `IntelligentScissors.cpp` are a barebones template for your work. 20 | Feel free to make any change to the API. 21 | 22 | The file `main.cpp` should be the entry point to your executable that performs the segmentation work. 23 | 24 | ### Coding styleguide 25 | Please write *clean and readable code*: 26 | * Use proper indentation, with spaces rather than tabs. 27 | * Always use curly brackets, for `if`s, `for`s, `while`s and everything else. No "orphan" statements, please. 28 | * Add spaces between operators, e.g. `a * b`. 29 | * Document methods and classes, both with inline comments and doxygen-esque documentation. 30 | * Use meaningful variable names. No single-character var names, please. 31 | * Split large functions to smaller, simpler chunks and [DRY](https://en.wikipedia.org/wiki/Don%27t_repeat_yourself). 32 | * Avoid deeply nested `if`s and `for`s. 33 | * Prefer C++11 features, e.g. using `and` over `&&`, smart `for`s: `for (int it : vector)`, using `auto`s, etc. 34 | * Do not leave code commented out. 35 | * Properly note the author and the date of file modification in the top of the source file. 36 | 37 | There is a standard `Makefile` for you to use for compiling. It assumes a Unix-like OS. 38 | 39 | [1] Kass, Michael, Andrew Witkin, and Demetri Terzopoulos. "Snakes: Active contour models." International journal of computer vision 1.4 (1988): 321-331. 40 | 41 | [2] Eric N. Mortensen and William A. Barrett. 1995. Intelligent scissors for image composition. In Proceedings of the 22nd annual conference on Computer graphics and interactive techniques (SIGGRAPH '95) http://dl.acm.org/citation.cfm?id=218442 42 | 43 | [3] GIMP plugins: http://wiki.gimp.org/wiki/Hacking:Plugins --------------------------------------------------------------------------------