Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...

Full Transcript

**L1** **MATLAB** - **High level technical computing language** with user-friendly interface - Stems from **MATrix** and **LABoratory**, based with the use of **matrices** - Product of **Mathworks**, its first version was released in **1984** **Application Fields in MATLAB** -...

**L1** **MATLAB** - **High level technical computing language** with user-friendly interface - Stems from **MATrix** and **LABoratory**, based with the use of **matrices** - Product of **Mathworks**, its first version was released in **1984** **Application Fields in MATLAB** - Control engineering - Applied mathematics - Science and engineering disciplines **Working Environment of MATLAB** - **Command Window** -- **main window** of the program, **results are also shown** here - **Command Prompt** -- where **commands are typed** - **Command History Window** -- **previously executed commands** appear here - **Current Directory** -- lower left part, specifies the active folder of MATLAB. It is the **folder work** **Working with MATLAB** - **Command Window** -- where user execute commands one by one - **Text Editor** -- where you can write **sequence of commands**, to formulate and execute a program in **batch mode** - These are known as **scripts** - Script File -- executed either **directly from the editor window** from the menu Debug -\> Run or by **typing the script's name at the command prompt** - Must be **saved in current directory** - **Extension** of the file type is **.m** - Scripts, together with functions, are called **M-Files** **L2** **Functions of MATLAB** - **imread**("filename") **--** used to **import image** into the memory and assign it to a variable - **imshow**(variablename) **--** used to **display image** data that is stored to a variable - **imshowpair**(variable,variable,"montage") **--** used to **display two images together** - **montage --** places the images **side by side** - **imwrite**(variable,"name") **--** used to **export data** stored in MATLAB into an image file, output file format is automatically identifies based on file extension - **size**(variable) **--** used to **find the size of an array(image),** **returns a vector** - **first element --** number of **rows** (height) - **second element --** numbers of **column** (width) - **third element --** third dimension of the array, **RGB color planes** - **I(num,num,num) --** used for **extracting color planes RGB** - **max**(variable, \[\], "all") **--** used to **find largest value in an array** - **all --** finds maximum across **all values** in an array - **brackets --** required, placeholder for **unused input** - **min**(variable, \[\], "all") **--** used to **find smallest value in an array** - \[R,G,B\] = **imsplit**("variable") -- used to **extract all three color planes of an image array** - **montage**({R,G,B}) -- used to **display all three color planes** using montage **Definitions** - **Semicolon --** ending with this **stops MATLAB from displaying the values stored in a variable** - **Images --** contains **millions of values** - **Run / Run Section --** used to **execute scripts**, located in the MATLAB Toolstrip - **Unsigned 8-bit integer (uint8) -- used by most images**, stores integer from **0 -- 255** - **Bright Colored --** near **255** value - **Dark Areas --** near **0** value **L3** **Functions in MATLAB** - **im2gray**(variable) **--** used to **convert image to a grayscale**, results to having **2 dimensions** - **grayscale image --** single plane of intensity values - **intensity values --** computed as weighted sum of RGB planes - **imhist**(variable) -- used to **investigate the contrast of an image** by generating an intensity **histogram** - pixels binned at high and low ends = **good contrast** - **dark pixels** -- has intensity value **around 100** - **bright pixels** -- **not many** has intensity values **above 200** - **contrast** -- half of what it could be if the image used the full intensity range (0 -- 255) - **increasing contrast** = brightens bright pixels, darker dark pixels - **imadjust**(variable) -- **adjust the contrast of grayscale image** automatically - **only works for grayscale images, unless you provide additional input** - **imlocalbrighten**(variable) -- **adjust the contrast of colored images** **Definitions** - **purple values --** **not useful in classification algorithm** - **text --** one of the **essential identifying features** of a receipt - **receipt images --** should have good contrast for it to stand out - logical operators like **\< \>** generate arrays of the same size that contains logical values 1 0 - **logical operators** -- you can use them to **threshold the intensity values** of a grayscale image that will create a binary image - use threshold just below the peak to create better segmentation **L4** **Functions in MATLAB** - **imbinarize(variable)** -- **automate threshold selection process**, calculate the **best "threshold"** - **by default**, this uses **global threshold values** -- **same threshold for every pixel** in the image - **adaptive --** option **to look at smaller regions** and pick best threshold for that, 2nd argument - **imbinarize**(variable,"adaptive") - **by default,** **foreground** of an image is assumed to be **bright** and the **background**, **dark**; this is opposite of receipts - **ForegroundPolarity -- used to designate** whether foreground is bright or dark - **imbinarize**(variable,"adaptive","ForegroundPolarity","dark") - **binary mask --** apply it to images and analyze its contents, helps with image processing problem - **sum(variable,2) --** used to **compute sums across rows of an array**, it operates along the second dimension of the array, used to get the rowsum - distinctive pattern in rowsum signal, alternating **higher sums** (blank white space), **lower sums** (rows of text) this is absent for images without text - **plot(variable) --** used to **plot the rowsum** **L5** **Functions in MATLAB** - **fspecial**("average", n) -- used to **reduce the impact of the noise** in the binary image, it is an averaging filter, used to **create n-by-n averaging filter** - **imfilter**(image variable, averaging filter variable) -- used to **apply filter** to an image - **filter first** before binarizing image - **default setting** of this **sets pixels outside the image to zero** (unwanted dark outlines) - **imfilter**(image variable, averaging filter variable, **"replicate"**) -- uses pixel intensity values on the image border for pixels out side the image, used to **remove artificial border** **Definitions** - some receipt images have **elements that distort the text pattern's oscillation** - **noise** -- removal of this would make the text more prominent, **can interfere with receipt identification** by polluting regions in binarized image - **images taken in low light** -- becomes **noisy** due to increase in **camera sensitivity** **L6** **Functions in MATLAB** - **strel**("diamond",5) -- create a **structuring element** - this code defines as a **diamond-shaped** structuring element with a radius of 5 pixels - we can also create **disk and rectangle** element - **imclose**(variable,structuring) -- it performs **closing operation with the structuring element** - It **emphasizes and connects the brighter background**, removing thin dark lettering, thumb remains (larger background objects) - Final result is **image of background without the text** - It **isolates the background** for subtraction later - Subtracting higher intensity variable to lower one will result in negative intensities. Gs - Ibg - For positive intensities, subtract lower intensity variable with higher. Ibg - Gs - The subtraction from earlier inverts the intensities, in order to fix it and restore it to its original order, use inversion which is "\~." - Generate binary image using imbinarize then invert it. \~imbinarize() - **imbothat**(variable,structuring) -- used to **perform bottom hat transform** - **imopen**(variable,structuring) -- used to **emphasize dark text** instead of bright ones, opposite of imclose - using this with rectangle structuring element will turn lines of text into black horizontal stripes, which augments the valley **Definitions** - **background** -- in a receipt image is anything that is **not text** - **Adaptive threshold is not needed** with **good preprocessing** - **Bottom hat transform** -- closing an image, subtracting the original image from the closed image **L7** **Functions in MATLAB** - Oscillations -- contains peak region (white space) and valley region (text) - Find Local Extrema live task -- used to identify local minima or maxima in a signal automatically - In the activity, we set the input data to S, and set extrema type to Minima - In the default setting, there are many shallow minima identifies that don't correspond to rows of text **Definitions** - Minima should not be found in non-receipt images

Use Quizgecko on...
Browser
Browser