Siddharth Meghwal
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Assignment 1 ## ELL715 - Digital Image Processing #### 1. Image denoted as _f(x, y)_, is transformed to image _g(x,y)_. _g(x,y)_ is 3 times larger along y-axis and 2 times larger along x-axis than _f(x, y)_. Also _g(x,y)_ is at 6 units horizontal and 7 units vertical distance from _f(x,y)_. <br> Write a code to do this. Show _f(x,y)_ and _g(x,y)_. <br> Compute _h(x,y)_ third image by rotating pixels of image 2 _g(x,y)_ by 75◦ degrees counter clockwise. Write a code to do this. <br> Show _f(x,y)_, _g(x,y)_ and _h(x,y)_. ##### Code ```matlab clc; clear all; close all; F=imread('C:\Users\pc\Desktop\ELL715\Assignment1\test1.jpg'); % f(x,y) imshow(F); %test image F=imresize(F, 0.04) %resize to show translation figure; imshow(F); F_ref = imref2d(size(F)) %referencing image F to x-y coordinates T=[2 0 0; 0 3 0; 6 7 1] %transformation - resize and translation matrix tform=affine2d(T); [G, G_ref]=imwarp(F,tform); % g(x,y) by transforming f(x,y) %The outputs are a spatially referenced image %specified by the image data G and its associated spatial referencing %object G_ref theta=-75; %anti-clockwise rotation by 75 degrees R=[cosd(theta) sind(theta) 0; -sind(theta) cosd(theta) 0; 0 0 1] %rotation matrix tform2=affine2d(R); [H, H_ref]=imwarp(G,tform2); % h(x,y) by rotating g(x,y) figure; subplot(1,3,1); %comparing f(x,y), g(x,y) and h(x,y) imshow(F, F_ref); title('f(x,y)'); subplot(1,3,2); imshow(G, G_ref); title('g(x,y)'); subplot(1,3,3); imshow(H, H_ref); title('h(x,y)'); ``` ##### Images <p align = "center"> <img width = 350 src=https://i.imgur.com/K1Xur65.jpg alt="3D diagram"> <figcaption align = "center">Fig 1.a: Input Image</figcaption> </p> <p align = "center"> <img width = 1080 src=https://i.imgur.com/sJjQy0I.png alt="3D diagram"> <figcaption align = "center">Fig 1.b: Output Images</figcaption> </p> ![]() ##### Conclusion The input image had to be within 10 times of 6 pixels to show noticeable translation, thus we chose spectrum as it is relatively unaffected by the pixelation caused by resizing. Details of _f(x,y), g(x,y), h(x,y)_: ```matlab F_ref = imref2d with properties: XWorldLimits: [0.5000 32.5000] YWorldLimits: [0.5000 24.5000] ImageSize: [24 32] PixelExtentInWorldX: 1 PixelExtentInWorldY: 1 ImageExtentInWorldX: 32 ImageExtentInWorldY: 24 XIntrinsicLimits: [0.5000 32.5000] YIntrinsicLimits: [0.5000 24.5000] G_ref = imref2d with properties: XWorldLimits: [7 71] YWorldLimits: [8.5000 80.5000] ImageSize: [72 64] PixelExtentInWorldX: 1 PixelExtentInWorldY: 1 ImageExtentInWorldX: 64 ImageExtentInWorldY: 72 XIntrinsicLimits: [0.5000 64.5000] YIntrinsicLimits: [0.5000 72.5000] H_ref = imref2d with properties: XWorldLimits: [0.1679 87.1679] YWorldLimits: [-62.4457 18.5543] ImageSize: [81 87] PixelExtentInWorldX: 1 PixelExtentInWorldY: 1 ImageExtentInWorldX: 87 ImageExtentInWorldY: 81 XIntrinsicLimits: [0.5000 87.5000] YIntrinsicLimits: [0.5000 81.5000] ``` Hence, we successfully implemented the transformations of scaling, translation, and rotation as directed and the resulting image references are in accordance with the theoretically expected output. #### 2. Take an 8-bit gray scale image and perform the following operations using MATLAB. ##### Initial Code ```matlab clc; close all; clear all; I=imread('C:\Users\pc\Desktop\ELL715\Assignment1\test2.jpg'); figure; imshow(I); title('8-bit Image'); G=im2gray(I); % Grayscale figure; imshow(G); title('8-bit Grayscale'); G0 = double(G)/255; % Normalization ``` <p align = "center"> <img width = 1080 src=https://i.ibb.co/kyLTX9V/Q2-8bit.png alt="3D diagram"> <figcaption align = "center">Fig 2.1: Input 8-bit Image</figcaption> </p> <p align = "center"> <img width = 1080 src=https://i.ibb.co/gTPNnyh/Q2-Grayscale.png alt="3D diagram"> <figcaption align = "center">Fig 2.2: Input 8-bit Grayscale Image</figcaption> </p> ##### a. –ve of the image, log and antilog of the image ```matlab A = 255-G; % negative in 8-bit figure; subplot(1,3,1);imshow(A); title('Negative Image'); const=2; B=const*log(1+(G0)); % Log Transformation subplot(1,3,2);imshow(B); title('Log Transformation'); C= exp(0.5*G0)-1; % Antilog transformation subplot(1,3,3);imshow(C); title('Antilog Transformation'); ``` <p align = "center"> <img width = 1080 src=https://i.ibb.co/xq64SXz/Q2-A.png alt="3D diagram"> <figcaption align = "center">Fig 2.a</figcaption> </p> ##### b. Apply Gamma correction for gamma = 0.4, 2.5, 10, 25 and 100 ```matlab const = 2.5; G1=const*(G0.^(0.4)); % Gamma correction G2=const*(G0.^(2.5)); G3=const*(G0.^(10)); G4=const*(G0.^(25)); G5=const*(G0.^(100)); figure; subplot(2,3,1); imshow(G); title('Original Grayscale'); subplot(2,3,2); imshow(G1); title('Gamma=0.4'); subplot(2,3,3); imshow(G2); title('Gamma=2.5'); subplot(2,3,4); imshow(G3); title('Gamma=10'); subplot(2,3,5); imshow(G4); title('Gamma=25'); subplot(2,3,6); imshow(G5); title('Gamma=100'); ``` <p align = "center"> <img width = 1080 src=https://i.ibb.co/w4HwbWB/Q2-B.png alt="3D diagram"> <figcaption align = "center">Fig 2.b</figcaption> </p> ##### c. 2, 3, 4 power of image ```matlab P1=G0.^(2); P2=G0.^(3); P3=G0.^(4); figure; subplot(2,2,1); imshow(G); title('Original Grayscale'); subplot(2,2,2); imshow(P1); title('Power=2'); subplot(2,2,3); imshow(P2); title('Power=3'); subplot(2,2,4); imshow(P3); title('Power=4'); ``` <p align = "center"> <img width = 1080 src=https://i.ibb.co/G0hm2Qn/Q2-C.png alt="3D diagram"> <figcaption align = "center">Fig 2.c</figcaption> </p> ##### d. Plot Bit-planes of image (show all the 8-plane images) ```matlab figure; B1=bitget(G,1); subplot(2,4,1); imshow(logical(B1)); title('Bit plane 1'); B2=bitget(G,2); subplot(2,4,2); imshow(logical(B2)); title('Bit plane 2'); B3=bitget(G,3); subplot(2,4,3); imshow(logical(B3)); title('Bit plane 3'); B4=bitget(G,4); subplot(2,4,4); imshow(logical(B4)); title('Bit plane 4'); B5=bitget(G,5); subplot(2,4,5); imshow(logical(B5)); title('Bit plane 5'); B6=bitget(G,6); subplot(2,4,6); imshow(logical(B6)); title('Bit plane 6'); B7=bitget(G,7); subplot(2,4,7); imshow(logical(B7)); title('Bit plane 7'); B8=bitget(G,8); subplot(2,4,8); imshow(logical(B8)); title('Bit plane 8'); ``` <p align = "center"> <img width = 1080 src=https://i.ibb.co/7yB5DBp/Q2-D.png alt="3D diagram"> <figcaption align = "center">Fig 2.d</figcaption> </p> ##### e. Plot the histogram of original image and apply Histogram equalization and plot the resulted image ```matlab figure; subplot(2,2,1),imshow(I); title('Original Image'); subplot(2,2,2), imshow(G); title('Grayscale Image'); subplot(2,2,3), imhist(G); title('Histogram of Grayscale'); H=histeq(G); subplot(2,2,4), imshow(H); title('Image Post Histogram Equalization'); ``` <p align = "center"> <img width = 1080 src=https://i.ibb.co/wCL30vW/Q2-E.png alt="3D diagram"> <figcaption align = "center">Fig 2.e</figcaption> </p> ##### f. Apply a transformation that highlights range [120,200] but preserves all other levels. ```matlab F=G; F((F>=120)&(F<=200))=255; % highlight figure; subplot(1,2,1); imshow(G); title('Original Grayscale'); subplot(1,2,2); imshow(F); title('Highlights Implemented'); ``` <p align = "center"> <img width = 1080 src=https://i.ibb.co/pyy70dG/Q2-F.png alt="3D diagram"> <figcaption align = "center">Fig 2.f</figcaption> </p> ##### Conclusion: The negative, log, and antilog of the test grayscale image came out to be as expected. For Gamma corrections and the powers of test image, the output becomes darker with increasing the parameter agreeing with expected behaviour. Increment in bit planes resulted in clearer images progressively. The two tasks of implementing histogram equalisation and selective highlights were successfully implemented on the test image. #### 3. Use the test image available on [link](https://drive.google.com/drive/folders/1kQgo9J9bgqCe3DOU3eB3G8MWpYYokhrJ) ##### Initial Code ```matlab clc; close all; clear all; load('Copy of testimage.mat'); figure; imshow(im); title('Original Image'); ``` <p align = "center"> <img width = 1080 src=https://i.ibb.co/gZCtPQc/Q3.png alt="3D diagram"> <figcaption align = "center">Fig 3</figcaption> </p> ##### a. Create a function to calculate the histogram and then implement histogram equalization on the test image without using inbuilt MATLAB functions ```matlab [m,n]=size(im); hist=zeros(1,256); % initialize histogram for i=1:m for j=1:n hist(im(i,j)+1)=hist(im(i,j)+1)+1; end end pdf=hist/(m*n); % probability distribution cdf=zeros(1,256); % continuous T=zeros(1,256); % pixel values cdf(1)=pdf(1); T(1)=round(cdf(1)*255); for i=2:256 cdf(i)=pdf(i)+cdf(i-1); T(i)=round(cdf(i)*255); end res=uint8(zeros(m,n)); for i=1:m for j=1:n res(i,j)=T(im(i,j)+1); end end % res is in the range [0,255] figure; subplot(2,3,1); bar(hist,0.3); title('Implemented Histogram'); subplot(2,3,2); imhist(res); ylim([0,16000]); title('Implemented Histogram Equalisation'); subplot(2,3,3); imshow(res); title('Implemented Equalised Image'); ``` <p align = "center"> <img width = 1080 src=https://i.ibb.co/PCtJd95/Q3-A.png alt="3D diagram"> <figcaption align = "center">Fig 3.a</figcaption> </p> ##### b. Use the built-in function on the same image and compare with the histogram from step 1. Check mean squared error of both matrices ```matlab in_built_hist=histeq(im); figure; subplot(2,3,1); bar(hist, 0.3); title('Implemented Histogram'); subplot(2,3,2); imhist(res); ylim([0,16000]); title('Implemented Histogram Equalisation'); subplot(2,3,3); imshow(res); title('Implemented Equalised Image'); subplot(2,3,4); imhist(im); ylim([0,16000]); title('In-built Histogram'); subplot(2,3,5); imhist(in_built_hist); ylim([0,16000]); title('In-built Histogram Equalisation'); subplot(2,3,6); imshow(in_built_hist); title('In-built Equalised Image'); mse=sum(sum((res-in_built_hist).^2))/(m*n); ``` <p align = "center"> <img width = 1080 src=https://i.ibb.co/7t22YVm/Q3-B.png alt="3D diagram"> <figcaption align = "center">Fig 3.b</figcaption> </p> ##### c. Apply adaptive histogram equalization (CLAHE) and compare with other mapped images ```matlab clahe=adapthisteq(im); %Results figure; subplot(4,2,1), imshow(im); title('Original'); subplot(4,2,2), imhist(im); ylim([0,16000]); title('Original'); subplot(4,2,3), imshow(res); title('Implemented Eq'); subplot(4,2,4), imhist(res); ylim([0,16000]); title('Implemented Eq'); subplot(4,2,5), imshow(in_built_hist); title('In-built Hist Eq'); subplot(4,2,6), imhist(in_built_hist); ylim([0,16000]); title('In-built Hist Eq'); subplot(4,2,7), imshow(clahe); title('CLAHE'); subplot(4,2,8), imhist(clahe); ylim([0,16000]); title('CLAHE'); ``` <p align = "center"> <img width = 1080 src=https://i.ibb.co/HzpQPfx/Q3-C.png alt="3D diagram"> <figcaption align = "center">Fig 3.c</figcaption> </p> ##### Conclusion: The results of our implementations for histogram and histogram equalisation closely matched the inbuilt MATLAB functions. Also, we successfully implemented adaptive histogram equalization (CLAHE) and compared with previous results. The MSE loss from 3.b is reported as: ```matlab mse = 6.3246 ```

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully