Artificial Intelligence Lab Report: Matrix Operations and Image Processing - Prof. Shehzad, Study Guides, Projects, Research of Artificial Intelligence

LAb Report of Artificial Intelligence

Typology: Study Guides, Projects, Research

2022/2023

Uploaded on 10/29/2023

rehan-10
rehan-10 🇵🇰

6 documents

1 / 10

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
COMSATS UNIVERSITY ABBOTABAD DEPARTMENT
OF
ELECTRICAL AND COMPUTER ENGINEERING
Submitted By:
NAME Registration
Ahmed Raheel Jadoon
FA21
-
BCE-015
Muhammad Rehan
FA21
-
BCE-002
Artificial Intelligence
Lab Report #: 2
Date: 2-Oct-2023
Course Instructor: Dr. Imran Shahzad
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download Artificial Intelligence Lab Report: Matrix Operations and Image Processing - Prof. Shehzad and more Study Guides, Projects, Research Artificial Intelligence in PDF only on Docsity!

COMSATS UNIVERSITY ABBOTABAD DEPARTMENT

OF

ELECTRICAL AND COMPUTER ENGINEERING

Submitted By:

NAME Registration

Ahmed Raheel Jadoon FA21^ -

BCE- 015

Muhammad Rehan FA21^ -

BCE- 002

Artificial Intelligence

Lab Report #: 2

Date: 2-Oct-

Course Instructor: Dr. Imran Shahzad

Question 1:

Declare a numpy matrix(4x4) and use the built-in operators to slice the matrix and print its centre elements only. Flowchart:

Discussion: This task involves creating a NumPy array 'Array' representing a 4x4 matrix of integers. Array slicing is used to extract a subarray 'Center_Elements' consisting of elements from rows 1 to 2 and columns 1 to 2. The ' Center_Elements ' array contains the central 2x portion of the original 'Array' matrix. This task demonstrates the use of NumPy for array manipulation and slicing.

Question 2:

Read a black and white image from the directory, and then slice it using the matrix slice operators and display the sliced Image.

Flowchart:

Program Code:

Output:

Program Code:

Output:

Discussion :

This task involves matrix addition using NumPy. Two NumPy arrays 'A' and 'B' are created, representing 4x4 matrices of integers. An empty result matrix is initialized, and nested loops are used to add corresponding elements of 'A' and 'B', storing the result in the 'C' matrix. This task showcases basic matrix operations with NumPy.

Question 4:

Discussion :

In this task we load an image ('lab2.jpeg'), initially displaying it in grayscale using Matplotlib. Subsequently, it iterates through the image's pixels, swapping black (pixel value

  1. with white (pixel value 255) and vice versa, effectively generating a negative or inverted version of the original image, which is stored in the 'a' array. Finally, the inverted image is displayed using Matplotlib. In summary, the code successfully loads an image, performs color inversion, and presents both the original and inverted versions, showcasing a straight

forward image processing.

Conclusion:

In these tasks, we harnessed Python's prowess, relying on essential libraries like NumPy for array operations and Matplotlib for image processing. Task 1 demonstrated NumPy's efficiency in array manipulation and slicing, while Task 2 showcased seamless NumPy- Matplotlib integration for precise image handling and extraction. Task 3 highlighted NumPy's computational efficiency in matrix operations, exemplified through simple matrix addition. Task 4 showcased the combined power of Matplotlib and NumPy in a fundamental yet effective image processing technique – color inversion. Python's versatility in data manipulation, matrix operations, and image processing shines through these tasks, making it an indispensable tool for various scientific endeavors. ----------------------------------------------------------------------------------------------------------------