Image resizing project in matlab (GUI)





EZresize allows you to resize an image easily and quickly by way of a
bilinear interpolation algorithm. Before running, place the images that
you wish to resize with in the folder that contains the program. To run,
at the command prompt, enter EZresize. Once the program is opened, enter
the filename of the image (ex. myfirstpic.jpg) in your MatLab current
directory and click get image. Enter your image size in the height and
width boxes accordingly and, when ready, click 'Resize It!'. If you
decide you would like to save the image, enter a file name (ex:
myresizedpic.jpg) in the 'File Name' field. When ready, click 'Save it'
and your image will be saved in your current MatLab directory. To edit a
new image, close all picture windows, and then repeat the above process.




%%%%%%source code%%%%%%%%%%


close all
clear all
clc




figure_color=[1 1 1];
panel_color=[0.5 0.5 0.5];
entryField_color=[1 1 1];

%Handles

hFigure=figure(...
'Units','Pixels',...
'Position',[1000 300 198 348],...
'Toolbar','none',...
'MenuBar','none',...
'NumberTitle','off',...
'Color',[.5 .5 .5],...
'Name','EZresize {Cadence Software Deveolpment}');

hPanel=uipanel(...
'Parent', hFigure,...
'Units','Pixels',...
'Position',[0 0 200 350],...
'BackgroundColor',panel_color);

hImageChoice=uicontrol(...
'Style','Edit',...
'Parent',hPanel,...
'Units','Pixel',...
'Position',[10 250 180 25],...
'String','car.jpg',...
'BackgroundColor',entryField_color);

hButton=uicontrol(...
'Style','pushbutton',...
'Parent',hPanel,...
'Units','Pixels',...
'Position',[25 300 150 20],...
'String','Get Image',...
'BackgroundColor',panel_color,...
'Callback',@imageChoice_callback);

hImageChoiceText=uicontrol(...
'Style','Text',...
'Parent',hPanel,...
'Units','Pixels',...
'Position',[10 270 180 20],...
'String','Enter the name of your image(.jpg):',...
'BackgroundColor',panel_color,...
'HorizontalAlignment','Center');


hWidthEditBox=uicontrol(...
'Style','Edit',...
'Parent',hPanel,...
'Units','Pixel',...
'Position',[10 200 180 25],...
'String','300',...
'BackgroundColor',entryField_color);


hWidthText=uicontrol(...
'Style','Text',...
'Parent',hPanel,...
'Units','Pixels',...
'Position',[10 220 180 20],...
'String','Enter Desired Width (in Pixels)',...
'BackgroundColor',panel_color,...
'HorizontalAlignment','Center');

hHeightEditBox=uicontrol(...
'Style','Edit',...
'Parent',hPanel,...
'Units','Pixel',...
'Position',[10 150 180 25],...
'String','200',...
'BackgroundColor',entryField_color);

hHeightText=uicontrol(...
'Style','Text',...
'Parent',hPanel,...
'Units','Pixels',...
'Position',[10 170 180 20],...
'String','Enter Desired Height (in Pixels)',...
'BackgroundColor',panel_color,...
'HorizontalAlignment','Center');


hButton2=uicontrol(...
'Style','pushbutton',...
'Parent',hPanel,...
'Units','Pixels',...
'Position',[25 120 150 20],...
'String','Resize It!',...
'BackgroundColor',panel_color,...
'Callback',@resizeButton_callback);

hImageWriteEditBox=uicontrol(...
'Style','Edit',...
'Parent',hPanel,...
'Units','Pixel',...
'Position',[10 60 180 25],...
'String','',...
'BackgroundColor',entryField_color);

hButton3=uicontrol(...
'Style','pushbutton',...
'Parent',hPanel,...
'Units','Pixels',...
'Position',[25 30 150 20],...
'String','Save Image',...
'BackgroundColor',panel_color,...
'Callback',@imageWrite_callback);

hImageWriteText=uicontrol(...
'Style','Text',...
'Parent',hPanel,...
'Units','Pixels',...
'Position',[10 80 180 20],...
'String','Enter a filename',...
'BackgroundColor',panel_color,...
'HorizontalAlignment','Center');

handle_list=...
[hFigure,hPanel,hImageChoice,...
hButton,hButton2,hButton3,...
hImageChoiceText,...
hWidthEditBox,...
hWidthText,...
hHeightEditBox,...
hHeightText,...
hImageWriteEditBox,...
hImageWriteText];

set(handle_list,...
'Units','Normalized');

%Callback Functions

function imageChoice_callback(hObject,eventdata)

img=imread(get(hImageChoice,'String'),'jpg');

% W=width
% H=height
% C=3 for RGB color images

[H W C]=size(img);
oldsize=size(img);

hFigure=figure(...
'Units','Pixels',...
'Position',[200 200 W H],...
'Toolbar','none',...
'MenuBar','none',...
'NumberTitle','off',...
'Color',figure_color,...
'Name','EZresize {Cadence Software Deveolpment}');

hAxes=axes(...
'visible','off',...
'Units','Pixels',...
'Position',[0 0 W H],...
'NextPlot','ReplaceChildren',...
'XLimMode','Manual',...
'YLimMode','Manual',...
'XLim',[1 W],...
'YLim',[1 H],...
'YDir','Reverse');

imagesc(img);

setappdata(hFigure,'UserData',img);

end %imageChoice_callback

function resizeButton_callback(hObject, eventdata)

%Get data
img=getappdata(hFigure,'UserData');
img=double(img);
oldsize=size(img);
H=str2double(get(hWidthEditBox,'String'));
W=str2double(get(hHeightEditBox,'String'));
newsize=[W H];

%Routine

% Scaling factor
factor = (oldsize(1:2)-1)./(newsize-1);

% Create new grid (foundation for image)
u = 0:newsize(1)-1;
v = 0:newsize(2)-1;
[U, V] = ndgrid(u, v);

% Make a conection between the new grid and the old size
u = u.*factor(1) + 1;
v = v.*factor(2) + 1;

% Compute the location of each new point relative to one nearest
% neighbor of the original image
U = U.*factor(1); U = U - fix(U);
V = V.*factor(2); V = V - fix(V);

% Perform interpolation element by element
U = repmat(U, [1 1 3]);
V = repmat(V, [1 1 3]);
N = (V-1).*((U-1).*img(floor(u), floor(v), :) - ...
U.*img(ceil(u), floor(v), :)) - ...
V.*((U-1).*img(floor(u), ceil(v), :) - ...
U.*img(ceil(u), ceil(v), :));

N=uint8(N);

[H W C]=size(N);

hFigure=figure(...
'Units','Pixels',...
'Position',[100 100 W H],...
'Toolbar','none',...
'MenuBar','none',...
'NumberTitle','off',...
'Color',figure_color,...
'Name','Resized Image');

hAxes=axes(...
'visible','off',...
'Units','Pixels',...
'Position',[0 0 W H],...
'NextPlot','ReplaceChildren',...
'XLimMode','Manual',...
'YLimMode','Manual',...
'XLim',[1 W],...
'YLim',[1 H],...
'YDir','Reverse');

imagesc(N)

setappdata(hFigure,'UserData',N);

end %resizeButton_Callback

function imageWrite_callback(hObject, eventdata)

F=getappdata(hFigure,'UserData');
H=get(hImageWriteEditBox,'String')
imwrite(F,H)

end %imageWrite_callback


end %EZresize






thumbnail
About The Author

Ut dignissim aliquet nibh tristique hendrerit. Donec ullamcorper nulla quis metus vulputate id placerat augue eleifend. Aenean venenatis consectetur orci, sit amet ultricies magna sagittis vel. Nulla non diam nisi, ut ultrices massa. Pellentesque sed nisl metus. Praesent a mi vel ante molestie venenatis.

9 comments

  1. i saw this project on Redwood college website.

    ReplyDelete
  2. May be. these are not all my projects.

    this is a collection of different projects for students

    ReplyDelete
  3. how m i supposed to run this program!? I tried it by saving the callback functions in different m files but still m unable to link the functions with the main function.

    ReplyDelete
  4. when i run my project i get this error
    Function definitions are not permitted at the prompt or in scripts.
    can any one help..?

    ReplyDelete
  5. yep same here..... when i run i also get this error... plz help plz

    ReplyDelete
  6. I was looking for something like this…I found it quiet interesting, hopefully you will keep posting such blogs….Keep sharing
    Software Photo Slideshow

    ReplyDelete
  7. Brain Tumor Detection Algorithm Using Watershed & Segmentation Methods

    Image Fusion Algorithm On MRI And CT Image Using Wavelet Transform Matlab Project
    https://www.youtube.com/watch?v=kaydbREu90w

    Iris Recognition System Using Discrete Cosine Transform DCT Full Matlab Project
    https://www.youtube.com/watch?v=6Vw4jpBQ40I

    A High Capacity Steganography Scheme for JPEG2000 baseline System Using DWT

    Automated Blood Cancer Detection Using Image Processing Matlab Project

    Content Based Image Retrieval Systems (CBIR) Using Improved SVM Technique

    Audio Noise Reduction from Audio Signals and Speech Signals Using Wavelet Transform

    Buy this full matlab project for more details log on to https://matlabsproject.blogspot.in/

    Contact:
    Mr. Roshan P. Helonde
    Mob: +91-7276355704
    WhatsApp No: +91-7276355704
    Email id: roshanphelonde@rediffmail.com

    ReplyDelete
  8. Advanced Techniques For Image Forgery Detection
    https://www.youtube.com/watch?v=Jyi4vhRl9k8&t=43s

    Micro Calcification Detection Using Wavelet Transform Full Matlab Project
    https://www.youtube.com/watch?v=ZhcbCb7KKmk

    Palm Print Recognition System Using Gabor Filter Full Matlab Project

    Improved SPIHT Algorithm With DWT For Image Compression

    An Improved DWT & Correlation Based Audio Steganography for Data Hiding

    An Improved Image Compression Using Embedded Zero-Tree Wavelet Encoding And Decoding Technique
    https://www.youtube.com/watch?v=BnJ5YlAmDg4

    EIGEN VALUE BASED RUST DEFECT DETECTION AND EVALUATION OF STEEL COATING CONDITIONS

    Buy this full matlab project for more details log on to https://matlabsproject.blogspot.in/

    Contact:
    Mr. Roshan P. Helonde
    Mob: +91-7276355704
    WhatsApp No: +91-7276355704
    Email id: roshanphelonde@rediffmail.com

    ReplyDelete
  9. A SECURE AND ROBUST HIGH QUALITY STEGANOGRAPHY SCHEME USING ALPHA CHANNEL

    A LSB BASED STEGANOGRAPHY FOR VIDEO STREAM WITH ENHANCED SECURITY AND EMBEDDING/EXTRACTION
    https://www.youtube.com/watch?v=ccrcdyMLa6c

    AUTOMATED FEATURE EXTRACTION FOR DETECTION OF DIABETIC RETINOPATHY IN FUNDUS IMAGES

    IMAGE ENHANCEMENT USING HISTOGRAM EQUALIZATION AND BRIGHTNESS PRESERVING BI-HISTOGRAM EQUALIZATION

    A ROBUST DIGITAL IMAGE WATERMARKING BASED ON JOINT DWT AND DCT

    NUMBER PLATE RECOGNITION BY NEURAL NETWORKS AND IMAGE PROCESSING

    Buy this full matlab project for more details log on to https://matlabsproject.blogspot.in/

    Contact:
    Mr. Roshan P. Helonde
    Mob: +91-7276355704
    WhatsApp No: +91-7276355704
    Email id: roshanphelonde@rediffmail.com

    ReplyDelete