Hands-On Computer Vision with Julia - Dmitrijs Cudihins - E-Book

Hands-On Computer Vision with Julia E-Book

Dmitrijs Cudihins

0,0
31,19 €

-100%
Sammeln Sie Punkte in unserem Gutscheinprogramm und kaufen Sie E-Books und Hörbücher mit bis zu 100% Rabatt.

Mehr erfahren.
Beschreibung

Hands-On Computer Vision with Julia is a thorough guide for developers who want to get started with building computer vision applications using Julia. Julia is well suited to image processing because it’s easy to use and lets you write easy-to-compile and efficient machine code.
.
This book begins by introducing you to Julia's image processing libraries such as Images.jl and ImageCore.jl. You’ll get to grips with analyzing and transforming images using JuliaImages; some of the techniques discussed include enhancing and adjusting images. As you make your way through the chapters, you’ll learn how to classify images, cluster them, and apply neural networks to solve computer vision problems. In the concluding chapters, you will explore OpenCV applications to perform real-time computer vision analysis, for example, face detection and object tracking. You will also understand Julia's interaction with Tesseract to perform optical character recognition and build an application that brings together all the techniques we introduced previously to consolidate the concepts learned.

By end of the book, you will have understood how to utilize various Julia packages and a few open source libraries such as Tesseract and OpenCV to solve computer vision problems with ease.

Das E-Book können Sie in Legimi-Apps oder einer beliebigen App lesen, die das folgende Format unterstützen:

EPUB
MOBI

Seitenzahl: 171

Veröffentlichungsjahr: 2018

Bewertungen
0,0
0
0
0
0
0
Mehr Informationen
Mehr Informationen
Legimi prüft nicht, ob Rezensionen von Nutzern stammen, die den betreffenden Titel tatsächlich gekauft oder gelesen/gehört haben. Wir entfernen aber gefälschte Rezensionen.



Hands-On Computer Vision with Julia
Build complex applications with advanced Julia packages for image processing, neural networks, and Artificial Intelligence
Dmitrijs Cudihins
BIRMINGHAM - MUMBAI

Hands-On Computer Vision with Julia

Copyright © 2018 Packt Publishing

All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.

Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.

Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.

Commissioning Editor: Aaron LazarAcquisition Editor: Sandeep MishraContent Development Editor: Tiksha SarangTechnical Editor: Supriya ThabeCopy Editors:Safis Editing, Vikrant PhadkayProject Coordinator: Prajakta NaikProofreader: Safis EditingIndexer: Aiswarya NarayananGraphics: Jisha ChirayilProduction Coordinator: Arvindkumar Gupta

First published: June 2018

Production reference: 1290618

Published by Packt Publishing Ltd. Livery Place 35 Livery Street Birmingham B3 2PB, UK.

ISBN 978-1-78899-879-6

www.packtpub.com

mapt.io

Mapt is an online digital library that gives you full access to over 5,000 books and videos, as well as industry leading tools to help you plan your personal development and advance your career. For more information, please visit our website.

Why subscribe?

Spend less time learning and more time coding with practical eBooks and Videos from over 4,000 industry professionals

Improve your learning with Skill Plans built especially for you

Get a free eBook or video every month

Mapt is fully searchable

Copy and paste, print, and bookmark content

PacktPub.com

Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and, as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at [email protected] for more details.

At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters, and receive exclusive discounts and offers on Packt books and eBooks.

Contributors

About the author

Dmitrijs Cudihins is a skilled data scientist, machine learning engineer, and software developer with more than eight years' commercial experience. His started off as a web developer, but later switched to data science and computer vision. He has been a senior data scientist for the last three years, providing consultancy services for a state-owned enterprise. There, he uses Julia to automate communication with citizens, applying different CV techniques and scanned image processing.

About the reviewer

Zhuo Qingliang (KDr2 online) works for paodingai, a fintech start-up in China that is dedicated to improving the financial industry using AI technologies. He has over 10 years' experience in Linux, C, C++, Java, Python, and Perl development. He is interested in programming, consulting, and participating in, and contributing to, the open source community (which naturally includes the Julia community). He maintains a website, KDr2, where you can find out more about him.

Packt is searching for authors like you

If you're interested in becoming an author for Packt, please visit authors.packtpub.com and apply today. We have worked with thousands of developers and tech professionals, just like you, to help them share their insight with the global tech community. You can make a general application, apply for a specific hot topic that we are recruiting an author for, or submit your own idea.

Table of Contents

Title Page

Copyright and Credits

Hands-On Computer Vision with Julia

Packt Upsell

Why subscribe?

PacktPub.com

Contributors

About the author

About the reviewer

Packt is searching for authors like you

Preface

Who this book is for

What this book covers

To get the most out of this book

Download the example code files

Download the color images

Conventions used

Get in touch

Reviews

Getting Started with JuliaImages

Technical requirements

Setting up your Julia

Installing packages

Reading images

Reading a single image from disk

Reading a single image from a URL

Reading images in a folder

Saving images

Using test images

Previewing images

Cropping, scaling, and resizing

Cropping an image

Resizing an image

Scaling an image

Scaling by percentage

Scaling to a specific dimension

Scaling by two-fold

Rotating images

Summary

Questions

Image Enhancement

Technical requirements

Images as arrays

Accessing pixels

Converting images into arrays of numbers

Converting arrays of numbers into colors

Changing color saturation

Converting an image to grayscale

Creating a custom color filter

Applying image filters

Padding images

Padding with a constant value

Padding by duplicating content from an image

Blurring images

Sharpening images

Summary

Questions

Image Adjustment

Technical requirements

Image binarization

Fundamental operations

Image erosion

Object separation using erosion

Image preparation for text recognition

Image dilation

Merging almost-connected objects

Highlighting details

Derived operations

Image opening

Image closing

Top-hat and bottom-hat operation

Adjusting image contrast

Summary

Questions

Image Segmentation

Technical requirements

Supervised methods

Seeded region growing

Identifying a simple object

Identifying a complex object

Unsupervised methods

The graph-based approach

The fast scanning approach

Helper functions

Summary

Questions

Further reading

Image Representation

Technical requirements

Understanding features and descriptors

FAST corner detection

Corner detection using the imcorner function

Comparing performance

BRIEF – efficient duplicate detection method

Identifying image duplicates

Creating a panorama from many images

ORB, rotation invariant image matching

BRISK – scale invariant image matching

FREAK – fastest scale and rotation invariant matching

Running face recognition

Summary

Questions

Introduction to Neural Networks

Technical requirements

Introduction

The need for neural networks

The need for MXNet

First steps with the MNIST dataset

Getting the data

Preparing the data

Defining a neural network

Fitting the network

Improving the network

Predicting new images

Putting it all together

Multiclass classification with the CIFAR-10 dataset

Getting and previewing the dataset

Preparing the data

Starting with the linear classifier

Reusing the MNIST architecture

Improving the network

Accuracy – why at almost 70

Putting it all together

Classifying cats versus dogs

Getting and previewing the dataset

Creating an image data iterator

Training the model

Putting it all together

Reusing your models

Saving the model

Loading the model

Summary

Questions

Further reading

Using Pre-Trained Neural Networks

Technical requirements

Introduction to pre-trained networks

Transfer learning

MXNet Model Zoo

Predicting image classes using Inception V3

Setting up the Inception V3 environment

Loading the network

Preparing the datasets

Running predictions

Expected performance

Putting it all together

Predicting an image class using MobileNet V2

Setting up the environment

Loading the network

Preparing the datasets

Running the predictions

Expected performance

Putting it all together

Extracting features generated by Inception V3

Preparing the network

Removing the last Softmax and FullyConnected layers

Predicting features of an image

Saving the network to disk

Extracting features generated by MobileNet V2

Preparing the network

Removing the last Softmax and FullyConnected layers

Predicting features of an image

Saving the network to disc

Putting it all together

Transfer learning with Inception V3

Getting the data

Preparing the dataset

Extracting features

Creating a new network

Training and validating the results

Summary

Questions

Further reading

OpenCV

Technical requirements

Troubleshooting installation of Open CV

Troubleshooting installation on macOS

First steps with OpenCV

Updating OpenCV package source code

Defining Open CV location

Testing whether OpenCV works

Working with images

Converting OpenCV Mat to Julia images

Reading images

Saving images

Destroying the object

Image capturing from web camera

Face detection using Open CV

Object detection using MobileNet-SSD

Summary

Questions

Assessments

Other Books You May Enjoy

Leave a review - let other readers know what you think

Preface

Through this book, there will be a thorough guidance for all developers who want to get started with building computer vision applications using Julia. Julia is well suited for image processing because of its ease of use and the fact that it lets you write easy-to-compile and efficient machine code.

Readers will be taken through various packages that support image processing in Julia, and will also tap into open source libraries such as Open CV and Tesseract to find optimum solutions to problems encountered in computer vision. They will learn to build a full-fledged image processing application using JuliaImages, perform basic to advanced image and video stream processing with Julia's APIs, and much more.

Who this book is for

This book is for all those Julia developers who are interested in learning how to perform image processing, for those who want to explore the field of computer vision and wish to benefit from this book. A basic knowledge of Julia will help you understand concepts more effectively.

What this book covers

Chapter 1, Getting Started with JuliaImages,is about getting your first introduction to JuliaImages and ImageCore packages. We will be loading images from various sources and creating thumbnails, that is resizing and saving them back on disk in a different file format.

Chapter 2, Image Enhancement, is all about working with the ImageFiltering package. We will understand what linear and nonlinear filtering operations are and how they can be used to transform images, such as sharpening, blurring, and smoothing.

Chapter 3, Image Adjustment, will guide you through the ImageMorphology package. Morphological transformations are some simple operations based on the image shape that allow you to remove small noise, shrink objects, separate objects, and increase the object size or background space.

Chapter 4, Image Segmentation, will explore the ImageSegmentation package. Readers will learn how to use supervised and unsupervised methods to simplify or represent an image into something that is more meaningful and easier to analyze.

Chapter 5, Image Representation, will explore the ImageFeatures package. We will learn to compute compact descriptors or "features" in a form that permits comparison and matching of two images.

Chapter 6, Introduction to Neural Networks, will demonstrate the need for neural networks. We'll cover getting, preparing the data, and improving and predicting the images. This chapter will also teach you to classify datasets, training and putting it all together.

Chapter 7, Using Pre-Trained Neural Networks, will introduce you to pre-trained networks and help in predicting image classes using Inception V3 and MobileNet V2. It will also help to extract features generated by Inception V3 and MobileNet V2 and cover transfer learning using Inception V3.

Chapter 8, OpenCV, will demonstrate how to use the open source Open CV library to perform real-time computer vision analysis. We will learn to find faces on images and then track them on a video stream.

Chapter 9, Case Study – Book Cover Classification, Analysis and Recognition, will incorporate the various techniques that we've described all along the book to develop a Book cover classification, analysis, and recognition project.

To get the most out of this book

We are required to have Julia v. 1.0 or above installed

We need to ensure that our Julia environment has all the required prerequisites mentioned in every chapter

Download the example code files

You can download the example code files for this book from your account at www.packtpub.com. If you purchased this book elsewhere, you can visit www.packtpub.com/support and register to have the files emailed directly to you.

You can download the code files by following these steps:

Log in or register at

www.packtpub.com

.

Select the

SUPPORT

tab.

Click on

Code Downloads & Errata

.

Enter the name of the book in the

Search

box and follow the onscreen instructions.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

WinRAR/7-Zip for Windows

Zipeg/iZip/UnRarX for Mac

7-Zip/PeaZip for Linux

The code bundle for the book is also hosted on GitHub athttps://github.com/PacktPublishing/Hands-On-Computer-Vision-with-Julia. In case there's an update to the code, it will be updated on the existing GitHub repository.

We also have other code bundles from our rich catalog of books and videos available athttps://github.com/PacktPublishing/. Check them out!

Download the color images

We also provide a PDF file that has color images of the screenshots/diagrams used in this book. You can download it here: https://www.packtpub.com/sites/default/files/downloads/HandsOnComputerVisionwithJulia_ColorImages.pdf.

Get in touch

Feedback from our readers is always welcome.

General feedback: Email [email protected] and mention the book title in the subject of your message. If you have questions about any aspect of this book, please email us at [email protected].

Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details.

Piracy: If you come across any illegal copies of our works in any form on the Internet, we would be grateful if you would provide us with the location address or website name. Please contact us at [email protected] with a link to the material.

If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.

Reviews

Please leave a review. Once you have read and used this book, why not leave a review on the site that you purchased it from? Potential readers can then see and use your unbiased opinion to make purchase decisions, we at Packt can understand what you think about our products, and our authors can see your feedback on their book. Thank you!

For more information about Packt, please visit packtpub.com.

Getting Started with JuliaImages

This chapter is all about introducing the JuliaImages collection. JuliaImages is a collection of different packages that are used for image processing. We will look into the Images.jl and ImagesMetadata.jl packages, load and preview images from various sources, read metadata, resize and scale images, create thumbnails, and save them back to disk in a different format.

In this chapter, we will cover the following topics:

Setting up Julia

Reading images from various sources

Saving images in different formats

Cropping, scaling, and resizing images

Rotating images

Using test images

Technical requirements

Users are required to have Julia v. 1.0 or above installed. Julia can be downloaded from the official page at https://julialang.org/downloads/.

You can confirm your version number by typing VERSION into the Julia console or REPL, as shown in the following code snippet:

julia> VERSION

v"0.7.0-DEV.4465"

The Julia community does not keep sources other than the Julia website or GitHub up-to-date. Therefore, it is strongly advised to refer to the official website for the latest available version. For example, Ubuntu users get an older version when installing Julia using apt-get.

You should also clone or download a GitHub repository containing source code and sample images:

https://github.com/PacktPublishing/Hands-On-Computer-Vision-with-Julia

This can be done by going to the GitHub page and pressing either the Clone or Download button in the top right corner.

Setting up your Julia

Before we start working with our images, we need to ensure that our Julia environment has all the required prerequisites so that we can complete the chapter. We already confirmed that our Julia setup is correct, so let's proceed with installing the most essential packages from the JuliaImages collection.

Installing packages

The most essential packages from the JuliaImages collection are the following:

Images.jl

ImageMetadata.jl

ImageView.jl

TestImages.jl

These packages are all you need to perform simple tasks, and most regular users should be fine with the setup.

Run the following commands in the Julia REPL to get them installed and configured. If you have not used Julia before, it is very likely that these commands will install additional dependencies:

using Pkg

Pkg.add("Images")

Pkg.add("ImageMetadata")

Pkg.add("ImageView")

Pkg.add("TestImages")

Pkg.update()

The moment installation completes, it is advised that you verify whether the packages can be loaded. This is done by merely importing them into the current environment, waiting for new packages to compile, and seeing whether the command succeeds:

julia> using Images, ImageMetadata, TestImages, ImageView

There is a small chance that the preceding command will fail with an exception message stating that one of the packages does not exist:

ERROR: ArgumentError: Module XXX not found in current path.

Run `Pkg.add("XXX")` to install the TestImages package.

Please follow the instructions to install a missing package and repeat the steps from this chapter.

Windows users are required to complete additional steps to make the TestImages package work. Users are required to follow an extensive post-installation guide from the package page, http://juliaimages.github.io/TestImages.jl/, or from Chapter 9, Case Study – Book Cover Classification, Analysis, and Recognition.

Reading images

There are multiple different sources for your images. Let's look into three of the most popular methods:

Reading images from disk

Reading images from URL

Reading multiple images in a folder

Start by loading the Images package and verifying your current working directory using pwd:

julia> using Images

julia> pwd()

"/Users/dc/reps/packt-julia"

If pwddoes not correspond to your project folder, you have two options:

Start Julia from a folder that does correspond

Use the

cd

function to change it

The cd function accepts a single argument—the local path. An example of using the cd function would be as follows:

cd("~/repositories/julia-hands-on") # Unix-like systems

cd("C:\\repositories\\julia-hands-on") # Windows users

When you are all set, you can proceed to load your first image.