Home

document - OHM ECCE - Ateneo de Manila University

image

Contents

1. n show error T Save Error save file dlg gt Destroy void resizer Frm menu_Quit Close void resizer Frm set image properties wxString label image properties label as parameter sidebar DestroyChildren tool panel CreateToolPanel sidebar label _sidebar gt SizeWindows wxFoldPanel temp 0 for size t i 0 1i lt _tool_panel gt GetCount it temp tool panel gt Item 1i _tool_panel gt Expand temp void resizer Frm menu_About wxString message message Printf T Welcome to The Image Resizer using n Bicubic Interpolation by nElaine Ramos Mn JP Talusan nIsadelle De Guzman wxMessageBox message T About void resizer Frm OnClose wxCloseEvent amp event if event CanVeto amp amp wxGetApp number_ of windows gt 0 wxString message message Printf T d windows still open proceed with exit wxGetApp number of windows if wxMessageBox message T Please confirm wxICON QUESTION wxYES NO wxY GI S 49 event Veto return else For closing all child windows wxMDIChildFrame pChild GetActiveChild int nChildren GetChildren GetCount int nCount 0 while nCount nChildren 1 if pChild gt Close false false return nCount t t Activ
2. int resizer app number of windows void return window count 39 A2 1 5 resizer_App h Ya maa ea ar a a a a ee Name resizer App h Author Description Declaration for the resizer app class TE Part of the Image Resizer project for ELC 152 PPR R SSSR TSR SSS RRS SRS SRR CS RR SHR RS SSeS SRS SSSR Oo RSS SSS SRS Sa SR Sees eS ifndef _RESIZER APPH define _ RESIZER APP H _ ifndef WX PRECOMP include lt wx wx h gt ls include lt wx wxprec h gt ndif class resizer app public wxApp private int window count public bool OnInit int OnExit void Increase void void Decrease void int number of windows void Ji endif A2 1 6 resizer_Chl cpp Name resizer Chl cpp Author Description resizer Chl class implementation include resizer Frm h include resizer App h include resizer Chl h include my canvas h Do not add custom headers between Header Include Start and Header Include E wxDev Ct designer will remove them Header Include Start include lt wx app h gt include lt wx init h gt include wx settings h Header Include End E 5 Q 40 DECLARE APP resizer
3. DR temp gt Set EN WX WX DefaultSize wxSize 200 30 return temp temp gt SetOrientation wxLAYOUT VERTICA temp gt SetAlignment wxLAYOUT LEFT temp gt SetSashVisible wxSASH RIG temp gt SizeWindows new wxSashl BORD DefaultPosi E ER THEM i HT true menu LayoutWindow this SIDE tion wxSize 200 30 BAR wxSW_3DBORDER dPanelBar resizer Frm CreateToolPanel wxWindow parent wxString Creates the wxFoldPanelBar from the GUI items listed in the class declaration wxFoldPanelBar temp new wxFoldPanelBar parent wxID ANY wxDefaultPosition wxDefaultSize wxFPB DEFAULT STYLE wxFPB VERTICAL wxCaptionBarStyle cs cs SetCaptionStyle wxCAPTIONBAR RECTANGLE problem here wxFoldPanel panel templ temp AddFoldPanel T Properties true cs image properties new wxStaticText panel templ GetParent 7 7 IMAGE PROPERTIES msg temp gt AddFoldPanelWindow panel temp1 image properties wxFPB ALIGN WIDTH 5 20 wxFoldPanel panel_temp2 temp gt AddFold 45 Panel T Resizing Options true cs gt AddFoldPanel l AddFoldPane gt AddFoldPanel l gt AddFoldPanel l gt AddFoldPanel l gt AddFoldPanel l gt AddFoldPanel height label new wxStaticText panel temp2 GetParent
4. fendif 53 References 1 Giassa Matthew Engineering Medical Research and 3D Image Processing 2009 http www giassa net page_id 371 accessed September 2010 2 J Anthony Parker Robert V Kenyon and Donald E Troxel Comparison of Interpolating Methods for Image Resampling JEEE TRANSACTIONS ON MEDICAL IMAGING VOL MI 2 NO 1 MARCH 1983 3 Joshoua C Esmenda Mark Andrew S Mateo and Jerome Vergil S Paez Image Resizer Quezon City Department of Electronics Computer and Communications Engineering 2008 4 Lancaster Don Welcome to Don Lancaster s Guru Lair 2007 www tinaja com glib pixintpl pdf accessed September 2010 5 Michael Unser Philippe Thevanaz and Leonid Yaroslavsky Convolution Based Interpolation for Fast High Quality Rotation of Images JEEE TRANSACTIONS ON IMAGE PROCESSING VOL 4 NO 10 OCTOBER 1995 6 William H Press Saul A Teukolsky William T Vetterling and Brian P Flannery Numerical Recipes The Art of Scientific Computing Third Edition New York Cambridge University Press 2007 7 Blake L Carlson wx mageResampler cpp implementation of the wxImageResampler class The University of Iowa http www koders com cpp fid944571151037ADD80CA4E890A042FA4CADBACDF23 a spx s 22Blake Carlson 22 L36 accessed October 2010 54
5. wxID ANY T Height wxDefaultPosition aspect ratio wxDefaultSize 0 T Height width label new wxs taticText panel temp2 GetParent wxID ANY T Width wxDefaultPosition wxDefaultSize 0 T Height new wx ASPECT RATIO T Lock Aspect Ratio CheckBox pan l temp2 GetParent wxDefaultPosition wxDefaultSize 0 wxDefaultValidator T Aspect Ratio height input new wxTextCtrl panel temp2 GetParent E HEIGHT INPUT wxEmptyString wxDefaultPosition wxDefaultSize wxTE RIGHT wxDefaultValidator T Height Input width input new wxTextCtrl pan l t mp2 GetParent WIDTH INPUT wxEmptyString wxDefaultPosition wxDefaultSize wxTE RIGHT wxString wxDefaultValidator T Width Input height input SetValidator validator width input SetValidator validator choices _T pixels T p dimensions new wxChoi DIMENS wxDefa wxDefa dimensions SetSelectio in pixel s true apply resize new wxBu temp Window panel te temp Vindow panel te temp Vindow panel te temp temp Vindow panel te Vindow panel te temp Vindow panel te temp Vindow panel te return te mp ercent ce panel temp2 GetParent ION TYPE wxDefaultPositi
6. wxUint8 src source GetData The wxImage GetData returns the image data as an array in RGBRGBRGB format Since the data retrieved is in unsigned char data type wxUint8 is used The derivatives are computed by multiplying the location of the pixel in the new image to the ratio of the old dimension to the new dimension Then the largest integer value of f y is subtracted to the value of f y f y float y yScale i y int floor f y a f y float floor f y f x float x xScale i x int floor f x b f x float floor f x Then the obtained values are passed through resizer Frm b3spline which performs bicubic spline If the derivative obtained is less than zero then it is set that the output would be 0 5 wxlmageResampler cpp implementation of the wxImageResampler class 21 if x 2 0 lt 0 0f a 0 0f else a float pow x 2 0f 3 0 if x 1 0 lt 0 0f b 0 0f else b float pow x 1 0f 3 0 if x lt 0 c 0 0f else c float pow x 3 0f if x 1 0 lt 0 0f d 0 0f else d float pow x 1 0f 3 0 return 0 16666666666666666667 a 4 0f b 6 0f c 4 0 d To get the location of the source pixel the width of the original image is multiplied to the height of the original image and then added to the width of the orignal image Since the wxImage GetData is used it is multiplied by three src
7. 43 wxTextValidat wxTextValidator wxFILTER INCLUDE T Quit the Application about_menu gt Append MDI_ABOUT _T amp About tF1 mit wxMenuBar menu bar menu bar gt Append file menu menu bar gt Append about menu return menu bar WX or validator Accepts only 0 9 wxTextValidator input validator wxArrayString array More Tinto rmat sony new wxMenuBar wxT amp File T amp Help new CHAR LIST NULL array Add 0 array Add 1 array Add 2 array Add 3 array Add 4 array Add 5 array Add 6 array Add 7 array Add 8 array Add 9 input_validator gt SetIncludes array return input_validator Event Table Start BEGIN EVENT TABLE resizer Frm wxMDIParentFrame EVT UPDATE UI wxlD ANY resizer Frm OnUpdate EVT MENU wxID ANY resizer Frm OnMenu EVT CLOSE resizer Frm OnClose EVT SIZE resizer Frm OnSize EVT SASH DRAGGED SIDEBAR resizer Frm OnSashDrag EVT CHECKBOX A SPECT RATIO resizer Frm OnCheck EVT CHOICE DIMENSION TYPE resizer Frm OnChoice EVT BUTTON APPLY TO_IMAGE resizer Frm OnApply EVT TEXT wxID ANY resizer Frm END EVENT TABLE PEE resi Event Table End zer Frm wxMDIParentFr
8. in pixels ring resizer Frm get height input void height input GetValue ring resizer Frm get width input void width input GetValue label wxString label input gt ChangeValue label void resizer Frm set width label wxString label _width_input gt ChangeValue label void resize wxLayout layout void resize TE _sideba wxLayout layout Get event Get return r Frm OnSize wxSizeEvent amp event tAlgorithm layout LayoutMDIFrame this r Frm OnSashDrag wxSashEvent amp event tDragStatus wxSASH STATUS OUT OF RANGE r gt Set tAlgo Layout tDefaultSize wxSize event GetDragRect width 1000 rithm layout tMDI Frame this tClientWindow gt Refresh 47 void resizer Frm OnMenu wxCommandEvent amp event selects handler function for the specific menu ID switch event GetId case MDI OPEN menu OpenFile break case MDI SAVE menu Save break case MDI QUIT menu Quit break case MDI ABOUT menu About break void resizer Frm menu Aspect Ratio wxCommandEvent event aspect locked event IsChecked void resizer Frm menu OpenFile wxString wildcards allowed image formats wildcards T Image Files bmp jpeg jpg png gif bmp jpeg j3pg png gif BMP files bmp bmp JPEG files jpeg jpg jpeg
9. jpg T PNG files png png WG GIF fries sgrt grtt wxFileDialog open file dlg new wxFileDialog this wxT Choose image file rh rh rh rh _T wxEmptyString wxEmptyString wildcards wxFD_OPEN wxFD FILE MUST EXIST I wxFD CHANGE DIR wxCENTRE if open file dlg 5ShowModal wxID OK wxString filename path extension filename open file dlg GetFilename path open file dlg gt GetPath wxFileName th mo path filename extension the file GetExt if open image filename show error T Error opening image file open file dlg gt Destroy Refresh void resizer Frm menu_Save wxString wildcards wildcards T BMP file bmp bmp T JPEG file jpg jpg T PNG file png png wxFileDialog sav file dlg new wxFileDialog this wxT Save Image 48 file wxEmptyString wxEmptyString wildc ards wxFD SAVE wxFD OVERWRITE PROMPT wxFD FILE MUST EXIST wxFD CHANGE DIR wxCENTRE if save file dlg ShowModal wxID OK wxString filename path extension filename save file dlg gt GetFilename path save file dlg gt GetPath wxFileName the file path filename extension the file GetExt if save_image filename
10. 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 D I 0 8 49 0 0 0 0 Q0 O0 0 Q9 32 3 0 0 2 Q0 9 iri 0 0 0 0 0 0 Q0 0 2 2 0 O0 1 1 0 9 0 3 0 0 d 0 2 0 L D 0 O O Q0 0 0 0 0 3 0 3 0 0 0 0 0 2 0 I 0 9 9 9 2 6 2 06 3 6 0 3 3 42 2 2 I 6 6 05 3 3 3 Qd 4 2 2 2 2 I el 2 0 2 0 0 0 0 0 1 0 lI 0 0 0 0 0 0 0 0 2 0 2 0 0 0 0 1 O0 1 O0 gt 6 6 6 d 2 4 2 3 3 3 3 2 2 l 4 4 4 4 2 2 2 2 2 2 2 2 1 IL i 1 The transposed 16x16 matrix which when multiplied to provides the values ofallthe Thus giving the path to obtain the pixel to be interpolated which is given by this final equation 3 3 p J K 2 9 31a 17 w 1 n m 0 n 0 17 2 Project Overview 2 1 Objectives The main objective of this project is to improve upon the image resizing program that was created two years ago by modifying their code which was made using the bilinear interpolation algorithm to a bicubic interpolation method The project is to be written in C for the same reasons as the previous groups as well as to make use of the wx Widgets within the compiler wxDev C This is an open source compiler which combines the Bloodshed Dev C with wxWidgets for creating graphical user interfaces This has the added capability of manipulating images through its wx classes such as wxImage and wxBitmap The previous groups code created their own image classes with which to display and operate the image f
11. B 1 and f A 1 B 1 and the partial derivatives fey and 557 f and the unused 4 cross derivatives 5 4 3 2 1 f 0 1 2 3 4 5 Figure 8 Placement of the points for bicubic splines 1 5 4 Bicubic Interpolation Since bicubic splines are just a special case of bicubic interpolation it lacks some functionality of bicubic interpolation that makes it more accurate While bicubic splines also make use of sixteen values the same as bicubic interpolation it does not make use of cross derivative values This trade off for accuracy results in much more complicated algorithm than the bicubic splines As said before the generalized bicubic interpolation now uses all of sixteen points discussed in the bicubic spline interpolation as well as the grid square It 4 Engineering Medical Research and 3D Image Processing 13 then attempts to reconstruct the exact surface between the four initial pixels by extracting from it the sixteen other pieces of information X A B X A 1 B X A B 1 X A 1 B 1 Figure 9 Grid Square for the Bicubic Interpolation Calculating these partial and cross derivatives based on the grid square above are as follows f A B f A 1 B f A 1 B f A 1 B BE ue a _ f A B 1 f A B 1 f A B 1 f A B 1 oa aa a ais f A pe AELE A a Be db EM A 1 4 1 x B 1 B 1 tA pj to a ca Se el A a uH 4 Using these values will enable the algorithm to find any inter
12. addons esed detis 6 1 4 Interpolation een eo eret oreet et ee ebrei rie era n iouis 7 1 5 Interpolation on Images e ete are pee eec te ane Norton s 7 1 5 1 Nearest NeIg DOR uu aa po ats eere ta edi net a a 7 1 52 Bilinear Interpolation sass nce rere rt reete re 9 1 5 3 ICU DIC Splings tee i ten i ebd e br Steg RR eased 11 1 5 4 Bicubic Interpolation 5 222 e oet tote etr ER ae wean 13 Z2 ProOJECt OVOLVIGW Sousa cinese tois tee AR p XU MN OU Soa LN I I SL OU De aiaa 18 2 LODIOGU VE donate dlc eue oc patte Suis tud dash Aes tbt eee M IRL IUE 18 2 2 Significance of the Project ders be irac tried MR 18 2 3 Scope and Limitations sesto troie np De eto RUE ride one E 19 RW bui M 20 3 1 Removing the Image class suene es ep FEE Pet ape reped d 20 3 2 Bicubic or Bilinear Interpolation esee 21 Ge GUISE Interface deesse re essa QUSE mud abdo rese uc cabo Peas 23 4l Progra FLOW v sacesaxsssutsacanesnsangeharsnaosaiweassatag veanatinbanssbelthsaniinensnaiaaanzers 25 6 Conclusions and Recommendations sese 27 GML Conclusions seh atqtie Giga EVequbata hs capud rese ites GR Me suu e tup n 27 6 2 Recommend a ONS nss n creta n qe o EV Da e lema a roe Deua 27 Appendix 1 User s Manual c3 roseo ded eate efe e eate tedteuts 28 AT T Software OVervIeW ss capestotid ue dst eiie top ded Qo beP dts iiaa iate 28 A1 1 1 Minimum System Requirements sss 28 Poll A 2h Eeaitit6s oet ties
13. app event handlers BEGIN EVENT TABLE resizer Chl wxMDIChildFrame EVT SIZE resizer Chl OnSize EVT CLOSE resizer Chl OnClose EVT ACTIVATE resizer Chl OnActivate END EVENT TABLE resizer Chl resizer Chl resizer Frm parent const wxString amp title 7 const wxImage amp the image wxMDIChildFrame parent wxID_ANY title wxDefaultPosition wxDefaultSize wxDEFAULT FRAME STYLE wxNO FULL REPAINT ON RESIZE display canvas new my canvas this title the image image_name title x zs my parent parent this gt SetClientSize display canvas GetClientSize this gt SetBackgroundColour wxColour T DIM GR Refresh resizer Chl resizer Chl void void resizer Chl OnSize wxSize Event amp even EY display canvas gt SetSize this gt GetClientSize display canvas gt Refresh void resizer Chl OnClose wxClosel wxGetApp Decrease my parent set image properties wx event Skip Event amp E E event mptyString void resizer Chl OnActivate wxActivateEvent amp event Sets the main frame item labels to reflect the activated child wxString height label width label temp labels height label Printf T d display canvas access height width label Printf T d display canvas access width temp labels
14. image is displayed the user has the option to save the image into the different formats supported by the program The program then saves a copy into the directory of the user s choice while retaining the dimensions of the resized image Saving and opening are handled by the image handlers in the wxWidgets library and saving is not available for GIF since the patent for that has recently expired 26 5 Conclusions and Recommendations S 1 Conclusions The group was able to develop an image resizer which performs using bicubic interpolation while using only the entire wxWidgets library The project was implemented with a graphical user interface that is able to open view save and resize the images of various formats This allows easier debugging and easier modification in the future 5 2 Recommendations The program created removes the image classes of the previous group in exchange for the wxWidgets libraries only this led to an easier to follow program and code for future modifications Further modifications could be made to feature other interpolation methods such as sinc and Lanczos interpolation methods and fractal algorithms like those used by Genuine Fractals Finally the code could be simply improved to perform faster 6 Comparison of Interpolating Methods for Image Resampling 27 Appendix 1 User s Manual A 1 Software Overview A1 1 1 Minimum System Requirements For modification WxDev C Updating of the curr
15. image properties wxString label is aspect locked void bool boo wxst wxst void void a int old_height new_heigh int void void void void void void void void void void void void is in pixel s void ring get height input void ring get width input void set height label wxString label set width label wxString label imensions of input height matrix User Input Related f OnApply wxCommandEven the image input width old width t new width unctions t amp event OnText wxCommandEvent amp event OnCheck wxCommand Event amp event OnChoice wxCommandEvent amp event OnMenu wxCommandEvent amp event menu About menu OpenFile menu Save menu Quit menu Aspect Ratio wxCo mmandEvent amp event menu Display wxCommandEvent amp event OnClose wxCloseEvent amp event Utility functions void show error wxString void open new child msg wxString amp title wxImage my image const const bool open image wxString filename 52 const wxString msg Error handling is in function bool save image wxString filename wxBitmap get active image void wxImage bicubic interpolation wxlmage amp source int newx int newy Float bicubicSpline float x DECLARE EVENT TABLE
16. int new height new width input height input width old height old width old height temp image GetHeight old width temp image GetWidth 33 users choices input height wxAtoi get height input input width wxAtoi get width input if input height 0 input width 0 amp amp input height old height amp amp input width old width wxMDIChildFrame active frame this gt GetActiveChild resizer Chl active child wxDynamicCast active frame resizer Chl name of image T Resized active child return image name for user input in pixels if in pixels new_height input_height new width input width for user input in percentage else new height input height old height 100 new width input width old width 100 resized image Bicubic temp image new width new height open new child name of image resized image else if input height old height amp amp input width old width wxMDIChildFrame active frame this gt GetActiveChild resizer Chl active child wxDynamicCast active frame resizer Chl name of image T Resized active child gt return_image_name open new child name of image temp image else show error T A zero in the input dimension is not allowed wxImage resizer Frm Bicubic wxImage amp source int new width int new heigh
17. Image Resizer Using Bicubic Interpolation A Project by Isadelle Mara de Guzman Elaine Valerie Ramos Jose Paolo Talusan Submitted to Luisito L Agustin Instructor ELC 152 In Partial Fulfillment of the Requirements for the Course ELC 152 Signal Processing Department of Electronics Computer and Communications Engineering School of Science and Engineering Loyola Schools Ateneo de Manila University Quezon City Philippines October 2010 ABSTRACT An image scaler is implemented using the C language The images were scaled using the method of bicubic interpolation Included in the project is a graphic user interface GUI in which both the input image and the rescaled output image can be viewed Image types such as BMP JPG PNG and GIF can be opened and scaled in the project Furthermore multiple images can be loaded and rescaled in the same GUI The images can then be saved in the form of BMP files JPG files or PNG files Acknowledgements God ECE Batch 2011 for their support and being there for us when the road looked tough ahead Sir Lui for this intense challenge greater than whatever we have encountered in 4 years of existence here in the Ateneo Table of Contents T Introduction ae cated alee ir coll bras a eati Mea E teas 6 MD NN CS csc cette eke iia E aa A Bad Seen McRae gaat eel T REIR 6 L1 RGB sce Sil sds Wine ies E ed DNE re Gin ay Ia la ao 6 T3 Image Resi ZENO du os qi atas edle tatam
18. Pos yy source GetWidth xx 3 To finally perform bicubic interpolation the interpolated value is computed by multiplying the pixel value to the bicubic spline with respect to height and width redPixel src srcPos rl r2 greenPixel src srcPostl rl r2 bluePixel src srcPos 2 r1 r2 22 4 User Interface The user interface of the resizer program was a modified program from the previous group s code and was again designed under the wx Widgets cross platform C GUI toolkit The graphical user interface of the program allows the user to open view and resize the following supported image files BMP JPG PNG and GIF files The main components of the graphical user interface include the status bar the menu bars the side bar and finally the main parent window Once an image has been selected and opened a child window opens from within the parent window displaying the name of the file while opening the child frame in its original size At the same time the properties of the image namely the file name and the dimensions in pixels Also it automatically loads and prints the values of the said picture unto the resizing options part of the side bar shown below Bicubic Interpolator E lena512bmp bmp Figure 10 Main window of the Program with image opened The main of the program for the GUI is found in the resizer App cpp and resizer_App h This controls the windows for the child fr
19. T Nn i AP DEL nam m image name temp labels temp labels T n i T Height in Pixels height label temp labels temp labels _T n i _T Width in Pixels width label temp labels temp labels T n if my parent is in pixels my parent set image properties temp labels my parent set height label height label 41 my parent set width label width label else my parent set image properties temp labels my parent set height label _T 100 my parent set width label T 100 my parent gt Refresh event Skip my canvas resizer Chl return canvas void return display canvas wxString resizer Chl return image name void return image name resizer Frm resizer Chl return my parent void return my parent A2 1 7 resizer Chl h Name resizer Chl h Author Description Declaration for the resizer Chl class Part of the Image Resizer project for ELC 152 ifndef RESIZER CHL H define RESIZER CHL H wxWidgets libraries included include lt wx wx h gt include wx mdi h include lt wx string h gt standard C libraries include lt cstdlib gt include lt string h gt other includes include my canvas h include resizer Frm h class resizer Chl public wxMDIChildFrame private
20. UT DIMENSION TYP APPLY TO IMAG ASPECT RATIO IMAGE PROPERTIES Menu Items MDI OPE MDI SAVE MDI DISPLAY MDI ABOUT MDI QUIT wxID EXIT Gl FI ZH be class resizer Frm private bool flags bool image_ok bool _in pixels bool _aspect_locked GUI items wxFoldPanelBar tool panel wxCheckBox aspect ratio wxStaticText height label wxStaticText width label wxStaticText wxTextCtrl height input identifies GUI items public wxMDIParentFrame image properties 51 wxTe xtCtrl width input wxChoice dimensions wxBu En protecte wxSa public Co resi wxString amp ti long style virt GU void void wxSa wxFo Us void void Accessor functions d GUI items d tton apply resize shLayoutWindow sidebar nstructor Deconstructor ze tle r Frm wxWindow pa rent const wxWindowID id const const wxPoint amp position const wxSize amp size ual I resizer Frm related functions OnUpdate wxUpdateUIEvent amp event InitToolBar wxToolBar toolBar shLayoutWindow CreateSash void ldPanelBar CreateToolPanel wxWindow parent er Input Related functions GUI related OnSize wxSizeEvent amp event OnSash Drag wxSashEvent amp event to this class void set
21. age bitmap void return image bitmap A2 2 my canvas h Name my canvas h Author Description Declaration for the my canvas class Part of the Image Resizer project for ELC 152 ifndef my canvas h define my canvas h 32 include lt wx wx h gt include lt wx scrolwin h gt include lt wx object h gt include lt wx bitmap h gt include lt wx icon h gt class my canvas public wxScrolledWindow private wxWindow the parent pointer to parent for quick access wxBitmap image bitmap for quicker rendering public Constructor Deconstructor my canvas wxWindow parent cons const wxString amp title wxImage amp temp image Ct Gt my canvas void Display the bitmap image from wxImage virtual void OnDraw wxDC amp dc Accessor functions int access height void int access width void wxBitmap return image bitmap void Ls endif A2 1 3 resizer_Algo cpp Name resizer Algo cpp Author Description Declaration for the my canvas class Part of the Image Resizer project for ELC 152 acts like main frame contd cpp include resizer App h include resizer Frm h include resizer Chl h DECLARE APP resizer app void resizer Frm OnApply wxCommandEvent amp event wxImage temp image get active image gt ConvertToImage wxImage resized image wxString name_of image
22. ame parent initialize member variables aspect ratio NULL height label NULL width label NULL height input NULL width input NULL dimensions NULL apply resize NULL tool panel NULL sidebar NULL imag properties NULL image ok false Creates the sidebar Sidebar CreateSash Sideba tool panel CreateToolPanel r SizeWindows 44 resizer Frm wxWindow parent const wxString amp title const wxSize amp size Ld OnText const wxWindowID id const wxPoint amp position const long style title position size style for sidebar sidebar wxEmptyString Applying keyboard shortcuts to the actions in the wxAcceleratorEntry shortcuts 4 shortcuts 0 Set wxACCEL CTRL int o MDI OPEN shortcuts 1 Set wxACCEL CTRL int s MDI SAVE shortcuts 2 Set wxACCEL ALT WXK F4 MDI QUIT shortcuts 3 Set wxACCEL CTRL WXK F4 CHILD QUIT shortcuts 4 Set wxACCEL NORMAL WXK F1 MDI ABOUT wxAcceleratorTable key shortcuts 5 shortcuts SetAcceleratorTable key shortcuts Create S tatus bar and toolba CreateStatusBar SetMenuBa r CreateMenuBar resizer Frm resizer Frm void DestroyChildren wxSashLayoutWindow resizer Frm CreateSash void wxCLIP CHI wxFol msg wxSashLayoutWindow temp
23. ames as well as to initialize the 23 main window for the application The resizer Frm cpp and its accompanying header files control all the events within the main frames ranging from the open close save and resize This also creates all the windows within the main application such as the menu bars status bars and the side bars Also this contains the main definition and declaration for the resizer_Frm which is the main application Also worth noting is that there is a wxFoldPanelBar present within this resizer Frm cpp that is not readily available within wxDev C Also within the resizer_Frm is the instantiation of the child frame which occurs when you open any image This calls upon the set image properties and displays the dimensions of the image within the sidebar Properties Y Filename lena512bmp bmp Height in Pixels 512 Width in Pixels 512 Resizing Options Y Height 512 Width 512 Lock Aspect Ratio Apply Resize Figure 10 side bar of the Program with image opened This side bar also allows the user to set the new dimension to which the currently opened image will be resized to There is also the option of resizing using pixels as well as with the percent size of the current image There is also the option to lock the aspect ratio of so that when either the height or width is set the other dimension will be automatically set to keep the same aspect ratio as the original image 24 This resizer Frm opens t
24. arent const wxString amp title const wxlImage amp temp image wxScrolledWindow parent wxID ANY wxDefaultPosition wxDefaultSize wxNO FULL REPAINT ON RESIZE the parent parent image bitmap new wxBitmap temp image 1 this SetClientSize wxSize image bitmap GetWidth image bitmap gt GetHeight this gt SetScrollbars 20 20 20 20 For scrollbars to know when scrollbars are needed If this is larger than SetSize scrollbars are produced this gt SetVirtualSize GetClientSize this gt SetSize GetBestSize my Canvas my canvas void For display of the bitmap image void my canvas OnDraw wxDC amp dc int width 0 height 0 int x 0 y 0 image_ height image width this gt GetClientSize amp width amp height image height image bitmap gt GetHeight 31 image width image bitmap gt GetWidth Algorithm to calculate so that image is always at the center of window if width lt image width x width image width 2 Algorithm to calculate so that image is always at the center of window if height lt image height y height image height 2 Draws the image dc DrawBitmap image bitmap x y false int my canvas access height void return image bitmap GetHeight int my canvas access width void return image bitmap GetWidth wxBitmap my canvas return im
25. ateNext pChild GetActiveChild event Skip void resizer Frm OnChoice wxCommandEvent amp event if _dimensions gt GetSelection 0 in pixels true else in pixels false set height label T 100 set width label T 100 A2 1 9 resizer_Frm h Name resizer Frm h Author Description Declaration for the resizer Frm class Part of the Image Resizer project for ELC 152 ifndef RESIZER FRM H define RESIZER FRM H _ wxWidgets libraries included include wx wx h include wx toolbar h include wx panel h include wx foldbar foldpanelbar h 50 lt wx laywin h gt lt wx mdi h gt lt wx file h gt lt wx filefn h gt lt wx menuitem h gt lt wx app h gt lt wx init h gt lt wx icon h gt lt wx defs h gt lt wx valtext h gt wx filedlg h wx progdlg h wx filename h wx xrc xmlres h wx msw helpchm h wx utils h wx stdpaths h wx wfstream h ude ude ude ude ude ude ude ude ude ude ude ude ude ude ude ude ude ude incl incl incl incl incl incl incl incl incl incl incl incl incl incl incl incl incl incl global functions wxMenuBar CreateMenuBar wxTextValidator validator enumeration of wxIDs enum SIDEBAR 100 HEIGHT INPUT WIDTH INP
26. d now also be rae f j 1 As seen from the figure below f ij 1 f i 1 j 1 q 1 p f Lj f i 1 j Figure 5 Grid Square used for Bilinear Interpolation As such the equation therefore would become flit p j a zl 1 p1 a fa j F Go 1 4 f G1 j 1 G 17 p FG j 1 GO f 17 Bilinear interpolation is often called close enough for government work 2 Since it produces an output image that is a good enough representation of the original image without the artifacts and blocks present in the nearest neighbor algorithm This algorithm has a good balance of speed and quality for most any use of resizing From this there are two distinct routes in order to improve the quality of interpolation 10 These are two use higher order methods remember that bilinear is simply a zero order method One of these methods is called the bicubic interpolation method not to be confused with the bicubic spline method From here on the term bi refers to operations in two dimensions i e the image grid 1 5 3 Bicubic Splines Bicubic splines is a lot like bilinear interpolation but instead of fitting all the data points along a certain line it is fitted along a curve of third degree y f x atbx ex dx hence a cubic spline As discussed before this would result in a more optimal output compared to lower degree methods Of course one curve cannot be the model for all of the points in the data set A cubic spline is def
27. ent packages Addition of the lib libwxmsw28 foldbar a to the compiler in the project options since the foldpanelbar used by the previous group is not found in the default settings of wxDev C For binary executable Windows 98 XP Vista e 256 MB RAM e 30 MB free hard disk space 5 75MB for executable extra for image e 256 or more colors compatible display A1 1 2 Features The Zmage Resizer allows the user to o Load Bitmap JPEG PNG and GIF images o View Bitmap JPEG PNG and GIF images o View multiple images o Resize an image and view the resized image o Save Bitmap JPEG and PNG images A1 1 3 Availability A12 User s Guide A1 2 1 Using the Software The program Image Resizer is designed to run on Microsoft Windows To run the program the executable file named Image Resizer is opened 28 A1 2 2 Loading Image Formats Go to the File Menu then click Open Image Also the keyboard shortcut Ctrl O could be used for loading the image on the program Upon loading the image the filename and dimensions of the image is seen in the side panel A1 2 3 Loading Multiple Images To open another image the same process as discussed in A1 3 2 is repeated A1 2 4 Resizing the Image After loading the image which is either in bitmap jpeg png or gif format the image could be resized by typing the desired width and height in the side panel The user has an option to tick the Lock Aspect Ratio If this option is c
28. erivatives 15 f 0 0 a f 1 0 a 2a 3a f 0 1 a 2a 3a 3 3 f 1 1 ba gt a mn m ln l Combining the coefficients 4 with the function values and the previously obtained partial and cross derivatives function values the output can be expressed in a matrix form M a B where is the matrix which contains the sixteen 4 coefficients 6 is the matrix which has the function values and its partial and cross derivatives and M is the coefficient matrix for a values B T e doo 4 10820 430401 O4 05 053 0 95015 055 A32 93 A13 A23 a33 B f 0 0 f 1 0 0 1 LDT ACA OAOA ALO 1 0 f 0 1 AS y O O OOOO ORORO e Ohl oo oo oc OOU OW OF O mG oo oorrRrRr Oo CcCoOoOrRF OO meer eRe rR Or Orr OOF COCO NONOGOrOFrFOCONCCOrFrOCC SO WOW Oorcdraoawneocoocnordcdeo aoOoocoonnNnNcoocooorree NNCGCONOGDWOCOOCOFrRF COFCO C SO ROC OCONCOCOCONOCOCOCOrOCC SO NOoOooOoOeOeNnrNcc TO OCOwWwWoCc OF COC SO oo ccu uu uococcoccoccoccoc c00c Ww C C US C QC oF KS oo eK Oo So S NOT OWCC ONC COFCO SO oonoowooownccordceo o ooooocooooooo FFF j ooooooo OFF Rr rR OF OO To compute for the interpolated value the sixteen 4 coefficients or the is needed From M p it is rewritten such that a Mi B 16 The transposed matrix M shown below 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 O0 0 O0 0 9 3 3 0 0 2 1 0 0 0 0 0 0 2 O0 0 O9 2 2 0 O 1 1 0 0 0 0 0 0 0 0 0 Q9 0 0 0 0 0 0 0 0 1 0
29. es aai ato peste pU tct Mad eaS 28 ALES Avalability eM GE Ue EU dpe ida eared lee ERR 28 AT 2 sers CUI eue sedes tides Machetes outa as tie pat 28 ATL2 1 Using the SoftWare mei oco a eiae 28 A1 2 2 Loading Other Image Formats esee 29 A1 2 3 Loading Multiple Images tie ovre o eot e 29 A1 2 4 Resizing the image oot ete tu ate ide der eodd 20 POV 2 Sc Saving the dB su eng teseqpigebi s ei ett euo Re baci ves Tuo eaaet 29 AT 2 6 Closing the image WindOW un eai eckibuece eere dts 29 Al 2 7 Closing the pr gr tn uuo het andae es tp tie pA IR eT Up m 29 Appendix Source Ode s ust eis ipie opea doxes beoe ai vu cube ue cd new IRURE 31 A2 T Source M Sr see est rte Reo etit npe e a 31 Bd IS my canvas epp ier oa i n e ess dta dus 31 A1 7 my AVIV ESA e tua Uae eto buie gt abono ua Brad idu tof 32 VN MN SI M Irure Mmm 33 ADANA resizer d CD Disk ies et EU Me pete ent e Nd 39 AO o FENZEF APP E ud ess bees tede eid Rusti oats reu uar t emp kESE 40 A2 1 0 FESIZeF CBLODD presiserer en norasta teagi oeii iml 40 POD NST VOSIZED Chl hrir aerea E ate ea PEE ed E AE 42 BD 1 8 FOSIZOP PH CDD asics esterase A R a RE e E e 43 AS resizer ATM Do eo te cce REEE EERE 50 References o as oU a Ms eM am DE 54 1 Introduction 1 1 Images Mathematically speaking an image is a set of points called pixels within a two dimensional grid This is a set of finite data points stored in a function suchas f i where i and j are t
30. gt source GetHeight yy source GetHeight 1 srcPosition yy source GetWidth xx 33 35 redPixel src srcPosition vertSpline horSpline greenPixel src srcPosition 1 vertSpline horSpline bluePixel src srcPositiont 2 vertSpline horSpline float resized image SetRGB x y redPixel greenPixel bluePixel return resized image resizer Frm bicubicSpline float x float a b c d if x 2 0f lt 0 0 a 0 0f else a float pow x 2 0f 3 0 if x 1 0f lt 0 0f b 0 0f else b float pow x 1 0f 3 0f if x lt 0 C 020 else c float pow x 3 0f 4 0 if x 1 0f lt 0 0f d 0 0f else d float pow x 1 0f 3 0f return 0 16666666666666666667f a 4 0f b 6 0 c d 36 void resizer Frm OnText wxCommandEvent amp event For calculating the other dimension when aspect locked if aspect locked wxString label int old height old width old height get active image GetHeight old width get active image GetWidth if event GetId WIDTH INPUT if in pixels Set height label get width input else int input width wxAtoi get width input int new height new height input width old height old width label Printf d new height set height
31. he child frame which contains the display object which is the my_canvas object The my_canvas object is in the my_canvas cpp which controls the display of the image by creating a buffer using wxBitmap This makes the program work and display image faster than the previous group This also has the capability to be able to open multiple child windows at the same time using the wxWidgets MDI or multiple document interfaces These are accessed by the resizer Chl cpp which controls the properties of the children windows such as the names its parents and the events when an image is closed Also this includes keyboard shortcuts for opening saving and closing windows and there is a help window in the about menu bar which details the steps in resizing an image 4 1 Program Flow Using the program interface in the menubar the user can open a file using the file open dialogue which prompts the user to select an image of the supported formats It just displays the image formats that are supported by the program and outputs and error if it is an invalid image Once an image is passed the program creates a wxImage container for the said image and it calls the open new child function as well as the my canvas as well as the resizer Chl cpp This opens the image with the parameters filename and the wxImage While at the same time the functions set 1mage properties and get dimensions labels are called to pass the values to the OnActivate in the resizer C
32. he number of columns and rows respectively and each intersection is called a pixel Pixels or picture elements are containers which store the values of the image depending on what color space it uses 1 2 RGB The most used color space is red green and blue or RGB Pixels store the intensity level of these values by assigning a number within 0 255 to it The closer the values to 255 the more intense and more white the pixel become The values of red green and blue are combined to reproduce an array of different other colors ranging from black zero intensity to white 1 3 Image Resizing Image resizing is the process of changing one or both of the dimensions of an image such that the output image will be of a different size either larger or smaller than the original image Since there would be a change in dimensions there would be new pixels present that were not in the original image These values are obtained using interpolation There is a need for interpolation since in order to resize the images it would need to calculate a number of unknown pixels obtaining their values from the pixels surrounding them unknown pixels are obtained using interpolation 1 4 Interpolation Interpolation is a process of fitting a continuous function to a discrete set of points This results in being able to obtain any other unknown points in between or beyond the said discrete set of points There are many functions being used to interpolate po
33. hecked the program automatically calculates the other dimension when one dimension is changed The user can also input the desired dimensions using percentage Finally in order to apply the new dimensions to the image press the Apply Resize button then the program resizes the image with accordance to the user s specifications A1 2 5 Saving the Image To save the image click the option Save Image in the File menu Also the keyboard shortcut Ctrl S could be used Then a dialog box where the user can input the filename and image type appears A1 2 6 Closing the image window The user can click the X button on the image window Also the user can go to the File menu then click the Close Image option A third option is to use the keyboard 29 shortcut Ctrl F4 A1 2 7 Closing the program The user can click the X button on the program window Also the user can go to the File menu then click the Quit Application option A third option is to use the keyboard shortcut Alt F4 30 Appendix 2 Source Code A2 1 Source Files A2 1 1 my_canvas cpp Name my canvas cpp Author Description my canvas class implementation kf Header files include my canvas h include resizer Chl h wxWidgets libraries included include lt wx dcbuffer h gt include wx dcclient h include wx dcmemory h include wx image h include wx wx h my canvas my canvas wxWindow p
34. hen placed unto a container labeled pixel this grouped the three int values into one container As it follows other parts of their code will also be modified such as the way it displays images rather than in their own class images will be displayed either using wxImage or wxBitmap By doing this the previous group s code has been made simpler to modify and translate for other projects since there has been no more need to wade through their image classes After removing the image class of the previous group the following functions were added to the resizer_Frm class in order to perform bicubic interpolation wxImage bicubic interpolation wxImage amp source int newx int newy float bicubicSpline float x where the first function performs bicubic interpolation and the second computes for the bicubic spline to be used in the bicubic interpolation 20 3 2 Bicubic Interpolation The bicubic interpolation implementation wxImage resizable_image bicubic_interpolation is found within the resizer_Algo cpp The ratio of the the old dimension with the new dimension is computed with xScale float source GetWidth float new width yScale float source GetHeight float new height where source GetWidth and source GetHeight obtains the dimensions of the original image and new width and new height are the new dimensions inputted by the user To get the data of each pixel the following function is used
35. hl cpp and passes these to the sidebar to display and take note for further use Once opened the image can now be resized When the dimensions have been edited while the lock aspect ratio button is checked there would be a call to the various functions to take into account the initial dimensions in inputting the new dimensions Using pixels or percentages of the current dimension the user selects new ones 25 Once the apply resize button is pressed the program calls these new dimensions as well as active image which is the current image window opened and passes it into the bicubic interpolation function In the same function once these variables are passed the program computes for the bicubic interpolation of every pixel on the image and stores them in a container redPixel src srcPosition vertSpline horSpline greenPixel src srcPositiontl vertSpline horSpline bluePixel src srcPosition 2 vertSpline horSpline which are then passed to the next function which places the new interpolated pixels unto a new wxImage set the RGB values using the values obtained resized image SetRGB u t R G B this wxImage is then returned and displayed return resized image open new child name of image resized image storing the values to a wxBitmap for quick display when called by the function dc DrawBitmap where dc means device context These are all handled by the resizer Chl cpp file Once the new resized
36. ined as a function that provides a value for any point between the data points j and k start and end of the data set being interpolated It must pass through all the original points in the set and it must be a number of piecewise continuous functions over several sub intervals which simply means that these different functions must be connected with each other The difficulty begins when the cubic splines must also have the same first derivative value on both sides of a point this also goes for the second derivatives Finally there is the case for the cubic spline to be either clamped or natural The natural boundary imagines the curve to pass through all points while the clamped attempts to extrapolate data from the end points The natural boundary condition is the one being satisfied by the curve in the future discussions Moving on to the computational aspect of bicubic splines much like bilinear 11 interpolation it needs to identify the four nearest neighbor pixels of the pixel to be interpolated X A B X A 1 B X A B 1 X A 1 B 1 Figure 6 Grid Square for Bicubic Splines but again a curve is needed to fit all the data points as shown by the figure below Figure 7 Output of the bicubic splines From this the values of the four points as well as their derivatives along any of the axes will be obtainable The original intensities of the surrounding pixels contribute four values 12 f A B f A 1 B f A
37. ints such as polynomials rational functions and also trigonometric functions The higher the order of the function is used to model the set of points the more accurately it depicts it although a function with sharp corners is more accurately depicted by a lower order of function As a final note there is no new data added by any interpolation scheme it will only draw all the values from the original grid 1 5 Interpolation on Images In the case of images it has to be interpolated along a grid in multi dimensions Instead of dealing with points in a line it deals with pixels as described above arranged in a two dimensional grid It has to model a pixel with respect to the intensity of the other pixels surrounding it to obtain an interpolated value In these cases there are two types of interpolation categories adaptive and non adaptive Adaptive algorithms produce optimal results because they are designed to adapt to the properties of the pixels surrounding the point to be interpolated Meanwhile non adaptive algorithms such as those described here produce sub optimal results by their inability to take into account how it treats other pixels depending on the pixel they are interpolation The up side to these is their simplicity of implementation 1 5 1 Nearest Neighbor The nearest neighbor function is the simplest form of interpolation This is where the value of a point to be interpolated is obtained from the values of the old coo
38. l panel GetCount i me ANY 1 bool resizer Frm save image wxString filename wxMDIChildFrame act resizer Chl active wxBitmap temp gt return_image bitmap wxImage temp_image return temp_image Sav wxBil resizer Chl wxMDIChildFrame active frame active child return active child gt return_canvas gt ret 38 this gt Get wxDynamicCas tive frame this gt GetActiveChild child wxDynamicCast active frame resizer Chl active child gt return_canvas temp ConvertToImage File filename tmap resizer Frm get active image void tActiveChild t active frame resizer Chl turn image bitmap A2 1 4 resizer App cpp Name resize App cpp Author Administrator Description include resizer App h include resizer Frm h IMPLEMENT APP resizer app bool resizer app OnInit wxInitAllImageHandlers window count 0 resizer Frm frame new resizer Frm NULL wxID ANY T Bicubic Interpolator wxDefaultPosition wxSize 800 600 wxDEFAULT FRAME STYLE wxHSCROLL wxVSCROLL SetTopWindow frame frame gt Show true frame gt Maximize true return true int resizer app OnExit return 0 void resizer app Increase void window _count void resizer app Decrease void window count
39. label label if event GetId HEIGHT INPUT if in pixels set width label get height input else int input height wxAtoi get height input int new width new width input height old width old height label Printf d new width set width label label ct ct void resizer Frm OnCheck wxCommandEvent amp event if _aspect_ratio gt GetValue aspect locked true aspect locked false void resizer Frm show error wxString msg wxMessageDialog error dialog new wxMessageDialog this 37 msg wxT ERROR error dialog gt ShowModa error dialog gt Destroy void resizer F rm open new ENTR Ed ebay LE Ea wxOK wxC child const wxSt const wxImage resizer Chl sub_fram wxGetApp Increase sub frame Show true image ok true wxFoldPanel temp 0 q E wxlICON ERROR tring amp title the image new resizer Chl this title the image for size t 0 temp tool panel tool panel gt Expan Refresh Open an image bool resizer Frm open_ima wxImage temp image fil if temp image IsOk open new child fil return true else re turn false Save an image Item i d temp ge wxString filena ename wxBITMAP TYP ename temp image aa I i too
40. my canvas display canvas resizer Frm my parent pointer to parent for access 42 wxString image name public Constructor Deconstructor resizer Chl resizer Frm parent const wxString amp title const wxImage amp the image virtual resizer Chl Event functions void OnSize wxSizeEvent amp event void OnClose wxCloseEvent amp event void OnActivate wxActivateEvent amp event Accessor functions my canvas return canvas void resizer Frm return my parent void wxString return image name void DECLARE EVENT TABLE define CHILD QUIT 4 ndif A2 1 8 resizer_Frm cpp Name resizer Frm cpp Author Description Resizer Frm class implementation include resizer App h include resizer Frm h include resizer Chl h DECLARE APP resizer app wxMenuBar CreateMenuBar wxMenu file menu new wxMenu wxMenu about menu new wxMenu file menu Append MDI OPEN T amp Open ImageNtCtrl 4O T Opens an image File l file menu Append MDI SAVE T amp Save ImageNtCtrl S T Saves the Image File file menu gt AppendSeparator file menu gt Append CHILD QUIT _T amp Close Image tCtrl X _T Close Active Image file menu gt AppendSeparator file menu gt Append MDI QUIT T amp Quit ApplicationNtAlt 4F4
41. on ultSize 2 choices 0 ultValidator T dimensions in n 0 tton panel temp2 GetParent APPLY TO IMAGE T Apply Resize wxDefaultPosition wxDefaultSize 0 mp2 height label wxFPB ALIGN WIDTH 5 20 mp2 height input wxFPB ALIGN WIDTH 5 20 mp2 width label wxFPB ALIGN WIDTH 5 20 mp2 width input wxFPB ALIGN WIDTH 5 20 mp2 dimensions wxFPB ALIGN WIDTH 5 20 mp2 aspect ratio wxFPB ALIGN WIDTH 5 50 mp2 apply resize wxFPB ALIGN WIDTH 5 25 void resizer Frm OnUpdate wxUpdateUIEvent amp event if event GetId MDI_ event Enable image o if event GetId CHIL event Enable image o SAVE k amp amp wxGetApp number of windows D QUIT k amp amp wxGetApp number of windows Gl 46 if event GetId APPLY TO IMAGE event Enable image ok amp amp wxGetApp number of windows if event GetId ASPECT RATIO aspect ratio SetValue aspect locked wxMenuBar menu bar this GetMenuBar wxM nu menu menu_bar gt GetMenu 1 menu gt Check ASPECT RATIO aspect locked SetMenu Bar menu bar bool resizer Frm is aspect locked void return _ aspect_locked bool resizer Frm is in pixels void void resizer Frm set heigh height return _ return _ return _
42. or their bilinear interpolation to be discussed later the group aims to modify this to remove certain redundancies in their code which improves certain parts of their program in exchange for some trade offs The graphical user interface will be the same as before although it would make things simpler for future modification of the code This will still be able to open save and resize images all while giving the user a view of the original and resized images Compatibility with the most often used formats is to be achieved this includes and is not limited to JPG BMP PNG and GIF 2 2 Significance of the Project Resizing is a frequently used process by programs and users alike that handle 18 images This is specifically needed when creating or transferring images for viewing to smaller or larger mediums such as HDTVs or mini sized LCDs such as digital cameras and other portable instruments The efficiency of any image resizing algorithm is measured by two main factors which are output image quality and computational complexity When resizing images it will be crucial to have a balance of the two having acceptable computational complexity and speed while having less blocks artifacts and blurring This project will be useful for other people needing to resize their images for their own program s uses such as image stitching or image cropping 2 3 Scope and Limitations The program since it was built on top of the previous g
43. polated value in the image output p x y and going back to figure 9 for references will give 16 various points of information depicted by the following 3 m 0 v PZ m 0 n Mvo a 1 w 1 A 0 x ll Me a _ y i h T 0 14 Me 2 3 m 0 3 ED ax l w i 0 a wyr 1 hy IM 3 These values again result in another unknown this time these are the coefficients amn this is obtainable by assuming that w and h are continuous over a unit square and redefine the four corners of the grid square in figure 9 as starting from the upper left hand clockwise as 0 0 1 0 f 0 1 f 1 1 this results in the sixteen coefficients Matching the interpolation surface p x y with the function values of the four corners the following four equations f 0 0 av f 1 0 agyt ayy Ay tayo FO D Sag 4o ao 403 3 3 f 1 1 2 2 do Fao taot dg dg Fay FA 4 a duin c Any ta t d4g a4 d45 44 are obtained Applying the same procedure with the horizontal and vertical derivatives the following eight equations the first four are for the horizontal derivatives and the latter are for the vertical derivatives f 0 0 ay f 1 0 a 2a54 3a4 f 01 Hay rau tag tdg 3 3 f Ain IM m 1n 0 f 0 0 a f 1 0 2ag a F aj t a f 0 1 2a 2a 3a 3 2 m 2 da Any n m 0 n 1 are derived Lastly four other equations are obtained from the cross d
44. rdinate 1 Numerical Recipes The Art of Scientific Computing Third Edition 7 point which is the value nearest to it This is the simplest of the interpolation techniques as it has the least ability to reproduce sharp image details especially at larger sizes This results in the resized image having excessive artifacts and degradation Shown below are the outputs of the various interpolation methods being used to recreate the discrete sinusoid wave in the figure 1 De Ed View Insert lods Desktop Window Help DUS k aano O08 8 Figure 2 Reconstruction of wave using Nearest Neighbor 2 Engineering Medical Research and 3D Image Processing as with subsequent graphs 8 Figure 1 Ele Edt Yew Insert Tools Qesitop Window Help OseS ki Qaaganrso 08 20 Figure 4 Reconstruction using Bicubic Interpolation 1 5 2 Bilinear Interpolation Bilinear interpolation stems from the one dimensional linear interpolation where the output of the function based on two known points f i and f i 1 ona single axis is given by f i p l p f i pf i 1 Moving on to two dimensions require this same equation done on the other axis Thus this requires four 3 Image Resizer points surrounding the pixel to be interpolated Instead of the initial two points f i f itl there woul
45. roups programming will be able to open and resize image formats BMP JPG PNG and GIF While being able to save them with the exception of GIF since its handlers are limited to opening only due to licensing Also worth noting is the absence of the RGBtext format since it is an obsolete image format which is severely limited in its abilities the only use it serves is for extensive testing and no more Also the removal of their image classes found in their image h and image cpp brings about certain limitations such as the absence of a dedicated function for interpolation But with the removal of the redundant classes it become easier to follow and track what is happening within the code since their classes are replace by simple wxImage class which are built in the compiler The scope of this project only covers bicubic interpolation and no other interpolation method 19 3 Code 3 1 Removing the image class In removing their image classes the group simply built a program from scratch taking snippets of their code while at the same time replacing functions and data types within the code from the old image class to the corresponding counterpart within the wx classes The basic flow of the past programming was to load an image and assign the RGB pixel values to their own fixed point class which was created by shifting the int data type obtained from getRed getBlue getGreen wx classes eight places to the left It was t
46. t wxCHECK MSG source Ok source wxT Invalid source wxImage passed to wxImageResampler Bicubic wxImage resized image new width new height true float xScale yScale xScale float source GetWidth float new width yScale float source GetHeight float new_height wxUint8 src source GetData long srcPosition 34 bicubic interpolation by Blake L Carlson lt blake carlson at uiowa dot edu float scaledWidth scaledHeight diffHeight diffWidth redPixel greenPixel bluePixel vertSpline horSpline int floorScaledWidth floorScaledHeight xx yy for long y 0 y lt new height y t scaledHeight float y yScale floorScaledHeight int floor scaledHeight diffHeight scaledHeight float floor scaledHeight for long x 0 x lt new width x scaledWidth float x xScale floorScaledWidth int floor scaledWidth diffWidth scaledWidth float floor scaledWidth redPixel greenPixel bluePixel 0 for int m 1 m lt 3 m vertSpline bicubicSpline float m diffHeight for int n 1 n lt 3 n horSpline bicubicSpline 1 0F float n diffWidth xx floorScaledWidth n 2 yy floorScaledHeight m 2 if xx lt 0 xx 0 else if xx gt source GetWidth XX source GetWidth 1 if yy lt 0 yy 0 else if yy

Download Pdf Manuals

image

Related Search

Related Contents

LG DLEX0001TM User's Manual  

Copyright © All rights reserved.
Failed to retrieve file