Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Similar to `get_is_row_inky`, Write the function `get_is_col_inky` that finds the columns with ink pixels and takes following the arguments: * `images`: A numpy array with

Similar to `get_is_row_inky`, Write the function `get_is_col_inky` that finds the columns with ink pixels and takes following the arguments: * `images`: A numpy array with the shape `(N,height,width)`, where * `N` is the number of samples and could be anything, * `height` is each individual image's height in pixels (i.e., number of rows in each image), * and `width` is each individual image's width in pixels (i.e., number of columns in each image). * **Note**: Do not assume anything about `images`'s dtype or the number of samples or the `height` or the `width`. and returns the following: * `is_col_inky`: A numpy array with the shape `(N, width)`, and the `bool` dtype. * `is_col_inky[i,j]` should be True if **any** of the pixels in the `j`th column of the `i`th image was an ink pixel, and False otherwise.

#Note the code from below

def get_is_row_inky(images): """ Finds the rows with ink pixels.

Parameters: images (np,array): A numpy array with the shape (N, height, width)

Returns: is_row_inky (np.array): A numpy array with the shape (N, height), and the bool dtype. """ is_row_inky = np.any(images, axis=2) return is_row_inky

------------------------------------------------------------------------------------------------------------------------------------------------------------------------

def get_is_col_inky(images): """ Finds the columns with ink pixels.

Parameters: images (np.array): A numpy array with the shape (N,height,width). Returns: is_col_inky (np.array): A numpy array with the shape (N, width), and the bool dtype. """

#REPLACE THIS CODE TO PASS THE TEST. IT KEEPS FAILING THE ASSERTION is_col_inky = np.any(images, axis=(1,2)) return is_col_inky

------------------------------------------------------------------------------------------------------------------------------------------------------------------------

#Assertion

(orig_image, ref_image, test_im, success_is_col_inky) = show_test_cases(lambda x: np.expand_dims(get_is_col_inky(x), axis=1), task_id='3_V')

assert success_is_col_inky

Error: It seems the test images and the ref images have different shapes. Modify your function so that they both have the same shape. test_images shape: (100, 1) #Fails here ref_images shape: (100, 1, 28)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Put Your Data To Work 52 Tips And Techniques For Effectively Managing Your Database

Authors: Wes Trochlil

1st Edition

0880343079, 978-0880343077

Students also viewed these Databases questions