📖 Scenario: Imagine you have a photo taken in low light. It looks dark and hard to see details. Image processing helps change this photo to make it clearer and easier to understand.
🎯 Goal: You will write a simple MATLAB program that loads a grayscale image, applies a brightness increase (a transform), and shows the original and changed images side by side. This shows how image processing transforms visual data to improve it.
📋 What You'll Learn
Load a grayscale image into a variable called img
Create a variable called brightness_increase with value 50
Add brightness_increase to img to create a new image called img_brighter
Display both img and img_brighter side by side using imshowpair
💡 Why This Matters
🌍 Real World
Image processing transforms help improve photos taken in poor lighting or with low contrast, making details easier to see.
💼 Career
Understanding basic image transforms is important for jobs in photography, medical imaging, security cameras, and computer vision.
Progress0 / 4 steps
1
Load the grayscale image
Write code to load the built-in grayscale image cameraman.tif into a variable called img using imread.
MATLAB
Hint
Use imread('cameraman.tif') to load the image.
2
Set the brightness increase value
Create a variable called brightness_increase and set it to 50.
MATLAB
Hint
Just write brightness_increase = 50;
3
Apply brightness increase to the image
Add brightness_increase to img and save the result in a new variable called img_brighter. Use uint8 to keep the image data type correct.
MATLAB
Hint
Convert img to double before adding, then back to uint8. Use min to avoid overflow.
4
Display original and brightened images side by side
Use imshowpair to display img and img_brighter side by side. Write a figure command before to open a new window.
MATLAB
Hint
Use figure; then imshowpair(img, img_brighter, 'montage');
Practice
(1/5)
1. Why do we use image processing to transform visual data in MATLAB?
easy
A. To make images easier for computers to analyze
B. To make images look worse
C. To delete images permanently
D. To convert images into text files
Solution
Step 1: Understand the purpose of image processing
Image processing changes images to help computers understand and analyze them better.
Step 2: Identify the correct goal
Making images easier for computers to analyze matches the purpose of image processing.
Final Answer:
To make images easier for computers to analyze -> Option A
Quick Check:
Image processing helps computers understand images = A [OK]
Hint: Image processing helps computers, not just humans [OK]
Common Mistakes:
Thinking image processing only improves visual quality
Confusing image processing with file deletion
Assuming image processing converts images to text
2. Which MATLAB command correctly converts an image to grayscale?
easy
A. imresize(image, 0.5)
B. rgb2gray(image)
C. imrotate(image, 90)
D. imwrite(image, 'file.jpg')
Solution
Step 1: Identify the function for grayscale conversion
The MATLAB function rgb2gray converts color images to grayscale.
Step 2: Check other options
imresize changes size, imrotate rotates, and imwrite saves images, so they are incorrect here.
Final Answer:
rgb2gray(image) -> Option B
Quick Check:
Grayscale conversion uses rgb2gray() = A [OK]
Hint: Grayscale means rgb2gray() in MATLAB [OK]
Common Mistakes:
Using imresize instead of rgb2gray
Confusing rotation with color change
Trying to save instead of convert
3. What is the output size of the image after running this MATLAB code?