Color image to gray πŸ“Έ, virtual environment πŸ‘¨πŸ»β€πŸ’», Detection VS Recognition πŸ€–, rest VS spread operator πŸŒͺ️

By Prajwal Haniya

Techeltter #63 | March 9, 2024

How do you convert a color image to a grayscale image?

I will be using the OpenCV library to process the image. It makes it a lot easier to process the image and build our application on top of it.

import cv2

# just call the below function with an image source

def convert_to_gray(image_src):
    image = cv2.imread(image_src)
    if image is not None:
        gray_image =  cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
        cv2.imshow('Color Image', image)
        cv2.imshow('Gray Image', gray_image)
        cv2.waitKey(0)
        cv2.destroyAllWindows()
    else:
        print('Error: Image not found');

What is the difference between object detection and recognition in ML?

Both the words look similar but they are not.

Detection involves identifying and localizing specific objects within an image or video, providing detailed information about their presence, location, and often the extent of objects of interest using bounding boxes.

Recognition focuses on categorizing objects in an image without the need for precise localization, primarily concerned with determining the correct object category rather than exact object placement.

Original link | Archive link


What do you mean by the virtual environment in Python?

A virtual environment in Python is a self-contained environment that isolates your Python development projects from the system-installed Python and other Python projects.

When you activate a virtual environment for a project, it becomes independent of the system-installed Python and its modules.

This isolation allows your project to have its own set of libraries, a separate Python interpreter, and its own pip for installing libraries.

How to create a virtual environment?

Install virtualenv library using the command:

pip3 install virtualenv

Now go inside the folder where you want to create a virtual environment and type the command:

python3 -m venv env

Now you need to activate the environment

source env/bin/activate

Replace env with any name you prefer for your virtual environment.

To exit out of virtual environment:

deactivate

What is the difference between the spread operator and the rest operator?

The spread operator is used to expand an iterable (like an array or string) into individual elements.

const arr1 = [1, 2, 3];
const arr2 = [...arr1, 4, 5]; // [1, 2, 3, 4, 5]

const obj1 = { a: 1, b: 2 };
const obj2 = { ...obj1, c: 3 }; // { a: 1, b: 2, c: 3 }

The rest operator is used to gather multiple elements into an array.

function sum(...nums) {
  return nums.reduce((acc, num) => acc + num, 0);
}
console.log(sum(1, 2, 3, 4));

const [first, ...rest] = [1, 2, 3, 4];
console.log(first); // 1
console.log(rest); // [2, 3, 4]

for (let i = 'a'.charCodeAt(); i <= 'z'.charCodeAt(); i++ {
     console.log(String.fromCharCode(i));
}

How far are we from automating front-end engineering?

Implementing visual designs of websites into functional code is challenging as it requires understanding visual elements and their layouts and then translating them into structured code.

Research paper link


Videos worth watching

  1. A conversation with the founder of NVIDIA
  2. How data engineering works?
  3. Bangalore water crisis explained

Other techletters from the archive

  1. Cognitive load 🧠, Health for SE πŸ§˜πŸ»β€β™‚οΈ, child process πŸ€– VS worker threads πŸ‘·β€β™‚οΈ
  2. Clean Code πŸ‘¨πŸ»β€πŸ’», parameter πŸ«™ VS arguments 🍷, for (each VS of) πŸŒ€, generics in programming πŸš€
  3. Product Market Fit πŸ‘¬πŸ»πŸ‘«πŸ», SQL ⛁, Tell a different story πŸ—£οΈ
  4. Caching πŸ—ƒοΈ, πŸ’²Shell Scripts βš™οΈ, Concurrency πŸ”€, Parallelism ⏸, Product Development πŸš€