4 Write a function that determines if a line is in the image

One condition that we will require in this lab is that the line or curve in the image spans the entire height of the image. That is, the line appears in the top row of the image and the line appears in the bottom row of the image (we will ignore cases where the line is discontinuous).

Complete the following function that returns true (1) if an image I contains a line that spans the entire height of the image and returns false (0) otherwise.

function tf = hasLine(I)
%HASLINE Does the image contain a height spanning line?
%   tf = hasLine(I) returns true if the image I contains
%   a line that spans the height of the image and false
%   otherwise.



You may assume that the image is black (has pixel value equal to 0)wherever the line occurs.

4.1 Testing your function

In the lab files that you downloaded you will find 10 test images. The images line1.png through line7.png are all examples of images containing a line spanning the height of the image; your function should return 1 when called with any of these images (change line1 to use a different test image):

I = imread('line1.png');
imshow(I)
tf = hasLine(I)

The images noline1.png through noline3.png are all examples of images that do not contain a line spanning the height of the image; your function should return 0 when called with any of these images (change noline1 to use a different test image):

I = imread('noline1.png');
imshow(I)
tf = hasLine(I)