Write a MATLAB function they determines the threshold level for grayscale images using Otsu’s method. Use the following function prototype:
function [ th ] = otsu(im)
% [ th ] = otsu(im)
% Find threshold level using Otsu's method.
% im: grayscale image of type uint8
% th: calculated threshold level, as a number between 0 and 1
Write a MATLAB function to determine the threshold level for grayscale images using the Kapur’s enthropy method described in http://pequan.lip6.fr/~bereziat/pima/2011/seuillage/kapur85.pdf
Use the following function prototype:
function [ th ] = enthropy(im)
% [ th ] = otsu(im)
% Find threshold level using enthropy method.
% im: grayscale image of type uint8
% th: calculated threshold level, as a number between 0 and 1
For convenience I used this test script to test otsu.m and enthropy.m.
Write a MATLAB function to find the angle of orientation of objects. Your code should show the result of the computation by drawing a line of white pixels over the original image. The line should have the object’s orientation and pass through the object’s center of mass. Your function should also report back the angle of orientation and the object’s column and row position on the command line. Use the following function prototype:
function [ angle, cc, cr ] = findangle(im)
% [ angle, cc, cr ] = findangle(im)
% Find the orientation of objects in grayscale image.
% im: grayscale image of type uint8
% angle: inclination angle
% cc: center of mass' column number
% cr: center of mass row number
You may use the code included in file pos.m to get started.
MY ANSWER: pos.m and two files findang.m and findangle.m.