NM Week2 Final
NM Week2 Final
OBJECTIVE:
1. To import, export, and display images in MATLAB.
2. To perform image transformations like rotate, resize, and flip.
3. To convert images to grayscale, binary, and HSV.
4. To separate RGB and HSV image planes.
5. To apply block operations on image regions.
6. To add noise and apply filters (Gaussian, Median).
7. To detect edges and contours in images.
8. To access and process video frames.
9. To capture and analyze webcam images.
10. To detect colors using HSV thresholding.
11. To draw shapes and add text to images.
12. To analyze pixel values and image details.
13. To display results in multiple figure windows.
PROCEDURE:
• Import images using imread, visualize with imshow, and export with imwrite.
Add shapes (line, circle) and text using insertShape and insertText. •
Separate RGB color planes and convert to HSV using rgb2hsv.
• Add noise using imnoise and reduce it using median filtering (medfilt2). • Detect
specific color regions (e.g., red) by thresholding hue component in HSV space.
1. Importing, Exporting and Visualizing
Images CODE:
% Import image
img = imread('img1.png');
% Display image
figure; imshow(img); title('Original Image');
% Display results
figure;
subplot(1,3,1); imshow(gray_img); title('Grayscale');
subplot(1,3,2); imshow(resized_img); title('Resized');
subplot(1,3,3); imshow(rotated_img); title('Rotated');
OUTPUT:
% Adjust contrast
adjusted_img = imadjust(gray_img);
% Display images
figure;
subplot(1,2,1); imshow(gray_img); title('Original Grayscale');
subplot(1,2,2); imshow(adjusted_img); title('Contrast Adjusted');
disp(['Pixel value at (100,150): ', num2str(pixel_value)]);
% HSV conversion
hsv_img = rgb2hsv(img);
% Display results
figure;
subplot(1,2,1); imshow(noisy_img); title('Noisy Image');
subplot(1,2,2); imshow(filtered_img); title('Filtered Image');
% Convert to HSV
hsv_img = rgb2hsv(img);
hue = hsv_img(:,:,1);
% Display mask
figure;
imshow(red_mask); title('Detected Red Regions');
RESULT:
Image resizing, rotation, and contrast adjustments were applied. Noise addition and
removal demonstrated filtering effectiveness. Color space conversions and region
detection aided image analysis.