Inspect image value

% At a given location (row, col):
dis(img(50, 100));

dis(img(50, :));

plot(img(50, :));
% At slice of the image:
disp(img(101:103, 201:203));

disp(size(img));
% Cropped size:
disp(size(cropped));

color planes

img = imread('fruit.png');
imshow(img);

disp(size(img));

img_red = img(:, :, 1);
imshow(img_red);

plot(img_red(150, 0));

Quantize an image

2.5, 0.7, 3, 6
3.7, 4.5, 1.9, 3.2
-1.3, 5.2, 7.5, 2.9
Levels:0,1,2,3,4,5

Round down:1.8 -> 1
Limits: <0 -> 0, >5 -> 5

each number always rounding down.

% Load and display an image
img = imread('dolphin.png');
imshow(img);

% Image size:
disp(size(img));

% Image class or data type:
disp(class(img));

hight 320
width 500
class uint8

u -> unsigned
int -> integer
8 -> 8bits

A little bit of pedagody

Computational Models(Math!)
Algorithm
Real Images

matlab
https://jp.mathworks.com/

GNU Octave
https://www.gnu.org/software/octave/

An image can be thought of as:
– a 2-dimensional array of numbers ranging from some minimum to some maximu
– a function I of x and y: I(x, y)
– something generated by a camera

Images as functions
we think of an image as a function, f or i, from R^2 to R
f(x, y) gives the intensity or value at position (x, y)
Piratically define the image over a rectangle, with a finite range:
f:[a, b]x[c, d] -> [min, max]
f(x,y) = [r(x,y) g(x,y) b(x,y)]

f:[10, 210]*[15.155] -> [0, 10]
(r,g,b) channels or planes

In computer vision we typically operate on digital images:
sample the 2d space on a regular grid
quantize each sample

Image thus represented as a matrix of integer values.
width 320, height 258, area 82560
3 color -> 82560*3 total color values

>> im = imread(‘peppers.png’); % semicolon or many numbers
>> imgreen = im(:,:,2);
>> imshow(imgreen)
>> line([1 512],[256 256],’color’,’r’)

OCR and Face Recognition

Optical character recognition(OCR)
technology to convert scanned docs to text
if you have a scanner, it probably came with OCR
Handwritten Digit recognition

Face detection
-most digital cameras can detect faces

Object recognition(in supermarket)
– Evolution Robotics Retail developed LaneHawk, a retail loss-prevention solution that helps turn bottom-of-basket(BOB) losses and in-cart losses into profits in real time.
– The company was acquired by Datalogic 5 year later!

Special effects: motion capture
Earth viewers(3D modeling)

Smart Cars
Vision-based interaction (and games)
Nintendo Wii has camera-based IR tracking build in.

Game changer:KINECT – skeleton technique

Security and curveillance
Medical imaging: 3D imaging MRI.CT image guided surgery

Taking over

Scene Understanding
sky, mountain, water, ground

how to build system
what is computer vision
-> Goal of computer vision is to write computer programs that can interpret images.

Image (and movies) have become ubiquitous in both production and consumption.
Therefore applications to manipulate images(movies) are becoming core.
As are systems that extract information from imagery
-surveillance
-building 3d representations
-motion capture assisted

Post request

client -> data -> server

func performThisclosure(closure: (void) -> void){
	closure()
}
func justDoIt(it: (Void) -> Void){
	it()
}
justDo {
	print("print me now!")
}
var somethingToDo: (Void) -> Void = {}

func doItLater(it: @escaping (void) -> Void){
	somethingToDo = it
}

subdomain

an extension to a domain name used to organize resources together

https://api.themoviedb.org/3/authentication/token/new?api_key=ENTER_YOUR_API_KEY_HERE

extension AppDelegate {
	
	func tmdbURLFromParameters{_ paramters: [String:AnyObject], withPathExtension: String? = nil) -> URL {

		var components = URLComponents()
		components.scheme = Constants.TMDB.ApiScheme
		components.host = Constants.TMDB.ApiHost
		components.path = Constants.TMDB.ApiPath + (withPathExtension ?? "")
		components.queryItems = [URLQueryItem]()

		for (key, value) in parameters {
			let queryUtem = URLQueryItem(name: key, value: "\(value)")
			components.queryItems!.append(queryItem)
		}
		return components.url!
	}}
}
private func getRequestToken() {

    /* TASK: Get a request token, then store it (appDelegate.requestToken) and login with the token */

    /* 1. Set the parameters */
    let methodParameters = [
        Constants.TMDBParameterKeys.ApiKey: Constants.TMDBParameterValues.ApiKey
    ]

    /* 2/3. Build the URL, Configure the request */
    let request = URLRequest(url: appDelegate.tmdbURLFromParameters(methodParameters as [String:AnyObject], withPathExtension: "/authentication/token/new"))

    /* 4. Make the request */
    let task = appDelegate.sharedSession.dataTask(with: request) { (data, response, error) in

        // if an error occurs, print it and re-enable the UI
        func displayError(_ error: String) {
            print(error)
            performUIUpdatesOnMain {
                self.setUIEnabled(true)
                self.debugTextLabel.text = "Login Failed (Request Token)."
            }
        }

        /* GUARD: Was there an error? */
        guard (error == nil) else {
            displayError("There was an error with your request: \(error)")
            return
        }

        /* GUARD: Did we get a successful 2XX response? */
        guard let statusCode = (response as? HTTPURLResponse)?.statusCode, statusCode >= 200 && statusCode <= 299 else {
            displayError("Your request returned a status code other than 2xx!")
            return
        }

        /* GUARD: Was there any data returned? */
        guard let data = data else {
            displayError("No data was returned by the request!")
            return
        }

        /* 5. Parse the data */
        let parsedResult: [String:AnyObject]!
        do {
            parsedResult = try JSONSerialization.jsonObject(with: data, options: .allowFragments) as! [String:AnyObject]
        } catch {
            displayError("Could not parse the data as JSON: '\(data)'")
            return
        }

        /* GUARD: Did TheMovieDB return an error? */
        if let _ = parsedResult[Constants.TMDBResponseKeys.StatusCode] as? Int {
            displayError("TheMovieDB returned an error. See the '\(Constants.TMDBResponseKeys.StatusCode)' and '\(Constants.TMDBResponseKeys.StatusMessage)' in \(parsedResult)")
            return
        }

        /* GUARD: Is the "request_token" key in parsedResult? */
        guard let requestToken = parsedResult[Constants.TMDBResponseKeys.RequestToken] as? String else {
            displayError("Cannot find key '\(Constants.TMDBResponseKeys.RequestToken)' in \(parsedResult)")
            return
        }

        /* 6. Use the data! */
        self.appDelegate.requestToken = requestToken
        self.loginWithToken(self.appDelegate.requestToken!)
    }

    /* 7. Start the request */
    task.resume()
}