<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-5740833303868793836</id><updated>2011-12-28T08:06:41.914-08:00</updated><title type='text'>Image Processing In Delphi</title><subtitle type='html'>Digital image processing using Delphi as the programming example. This is an online tutorial about digital image processing. This online tutorial is also provide Delphi source code download. The source codes for Turbo Delphi Explorer are also available. Here you can learn the digital image processing techniques by directly coding the source code in Delphi.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://imageprocessingindelphi.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5740833303868793836/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://imageprocessingindelphi.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>techtalk</name><uri>http://www.blogger.com/profile/06105126060926155997</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>20</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5740833303868793836.post-8974578899408572047</id><published>2020-07-24T19:53:00.000-07:00</published><updated>2009-05-03T22:40:01.383-07:00</updated><title type='text'>Table of Contents</title><content type='html'>&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;Chapter 1. Introduction&lt;br /&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size:100%;"&gt;&lt;a href="http://imageprocessingindelphi.blogspot.com/2008/06/introduction-to-image-processing-in.html"&gt;Introduction to Image Processing in Delphi&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://imageprocessingindelphi.blogspot.com/2008/07/image-processing-types.html"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-size:100%;"&gt;Image Processing Types&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;&lt;a href="http://imageprocessingindelphi.blogspot.com/2008/07/digital-image-format.html"&gt;Digital Image Formats&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-weight: bold;"&gt;Chapter 2. Delphi Components and Graphical User Interface&lt;/span&gt;&lt;ul&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;&lt;a href="http://imageprocessingindelphi.blogspot.com/2008/07/timage-image-component-in-delphi.html"&gt;TImage, An Image Component in Delphi&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;&lt;a href="http://imageprocessingindelphi.blogspot.com/2008/07/writing-simple-graphical-user-interface.html"&gt;Writing Simple Graphical User Interface for Image Processing&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-weight: bold;"&gt;Chapter 3. Image Histogram&lt;br /&gt;&lt;/span&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://imageprocessingindelphi.blogspot.com/2008/07/what-is-image-histogram.html"&gt;&lt;span style="font-size:100%;"&gt;What is An Image Histogram?&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;&lt;a href="http://imageprocessingindelphi.blogspot.com/2008/07/purpose-of-image-histogram-analysis.html"&gt;The Purpose of Image Histogram&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;&lt;span style="font-size:100%;"&gt;&lt;a href="http://imageprocessingindelphi.blogspot.com/2008/07/computing-and-displaying-image.html"&gt;Computing and displaying Image Histogram in Delphi&lt;/a&gt;&lt;/span&gt;&lt;/li&gt;&lt;/ul&gt;&lt;span style="font-weight: bold;"&gt;Chapter 4. Pixel Operation&lt;/span&gt;&lt;br /&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://imageprocessingindelphi.blogspot.com/2008/07/pixel-operation-introduction.html"&gt;Pixel Operation: An Introduction&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://imageprocessingindelphi.blogspot.com/2008/07/brightness-modification.html"&gt;Brightness Modification&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://imageprocessingindelphi.blogspot.com/2008/07/brightness-manipulation-in-delphi.html"&gt;Brightness Manipulation in Delphi&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://imageprocessingindelphi.blogspot.com/2008/08/contrast-enhancement.html"&gt;Contrast Enhancement&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://imageprocessingindelphi.blogspot.com/2008/08/coding-contrast-enhancement-in-delphi.html"&gt;Coding Contrast Enhancement in Delphi&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://imageprocessingindelphi.blogspot.com/2008/08/color-inversion.html"&gt;Color Inversion&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://imageprocessingindelphi.blogspot.com/2008/08/color-inversion-processing-in-delphi.html"&gt;Color Inversion Processing in Delphi&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://imageprocessingindelphi.blogspot.com/2008/08/rgb-to-gray-scale-conversion.html"&gt;RGB to Gray Scale Conversion&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://imageprocessingindelphi.blogspot.com/2008/08/rgb-to-gray-scale-conversion-using.html"&gt;RGB to Gray Scale Conversion Using Delphi&lt;/a&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://imageprocessingindelphi.blogspot.com/2008/08/thresholding.html"&gt;Thresholding&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://imageprocessingindelphi.blogspot.com/2008/08/threshold-below-threshold-above-and.html"&gt;Threshold Below, Threshold Above, and Threshold Inside Implementation in Delphi&lt;/a&gt;&lt;br /&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5740833303868793836-8974578899408572047?l=imageprocessingindelphi.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5740833303868793836/posts/default/8974578899408572047'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5740833303868793836/posts/default/8974578899408572047'/><link rel='alternate' type='text/html' href='http://imageprocessingindelphi.blogspot.com/2008/07/table-of-contents.html' title='Table of Contents'/><author><name>techtalk</name><uri>http://www.blogger.com/profile/06105126060926155997</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author></entry><entry><id>tag:blogger.com,1999:blog-5740833303868793836.post-98456170585006401</id><published>2008-08-10T20:44:00.000-07:00</published><updated>2008-08-10T22:09:39.576-07:00</updated><title type='text'>Threshold Below, Threshold Above, and Threshold Inside Implementation in Delphi</title><content type='html'>&lt;div style="text-align: justify;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;Image Format&lt;/span&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;a href="http://imageprocessingindelphi.blogspot.com/2008/08/thresholding.html"&gt;Image thresholding&lt;/a&gt;&lt;a href="http://imageprocessingindelphi.blogspot.com/2008/08/thresholding.html"&gt; process&lt;/a&gt; change the image to binary  value, zero or one. Ideally, this binary data is stored in the computer memory as  bit format, where 1 byte memory could store 8 pixels. Unfortunately, the modern computer hardware organization and software (compiler) technology doesn't handle the bit operation as fast and efficient as byte operation, so it is better to use ordinary 8bit or 24bit for practical reason, although it use actually only the least significant bit to store zero or one.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;The Graphical User Interface (GUI)&lt;/span&gt;&lt;br /&gt;To implement threshold various basic thresholding (below, above, and inside thresholding points), we need to design the graphical user interface first.&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;ol style="text-align: justify;"&gt;&lt;li&gt;Open our previous &lt;a href="http://imageprocessingindelphi.blogspot.com/2008/08/rgb-to-gray-scale-conversion-using.html"&gt;RGB to gray scale conversion&lt;/a&gt; project.&lt;/li&gt;&lt;li&gt;Create a new form, resize the form to fit the main form. Set the name property to ThresholdForm, and set the FormStyle to fsMDIChild. Save the unit as ThresholdUnit.pas.&lt;/li&gt;&lt;li&gt;On the menu Project-&gt;Options-&gt;Forms, select ThresholdForm (in the auto created form list) and click the &gt;  button, so the ThresholdForm will move from  auto created form list to available forms list, then press OK.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Add two CheckBoxes (from standard component pallet) to the form, set the name properties to InvertCheckBox and ThresholdInsideCheckBox. Set the captions to "Invert" and "Threshold Inside" respectively.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Add two ScrollBars (from standard component pallet) to the form. Set the name properties to LowScrollBar and HighScrollBar.  Set their maximum properties to 255. Set their position properties to 127. Add two labels to address them with "low" and "high" (see figure 1).&lt;/li&gt;&lt;li&gt;Add two buttons to the form, set their name properties to OKButton and CancelButton, and set their caption properties to OK and Cancel accordingly.&lt;/li&gt;&lt;/ol&gt;&lt;div style="text-align: justify;"&gt;To modify the image, it's common to backup the original image, so we can do a cancel operation after displaying the change on the original image form. To do this, we have to provide TImage object in the form to temporarily store the image. A procedure (SetThreshold) to associate the image input to the threshold form is also needed. To do this, edit the ThresholdForm abstraction (in the ThresholdUnit.pas)  to provide TImage (TemporaryImage and OriginalImage) object and the SetThreshold procedure declaration. A boolean flag (Applied) is also needed to mark whether a Cancel or OK button has been pressed. Add ExtCtrls under &lt;span style="font-weight: bold;"&gt;uses &lt;/span&gt;in the &lt;span style="font-weight: bold;"&gt;Interface &lt;/span&gt;section because use TImage component. After we edit the ThresholdForm abstraction, the code should look like below:&lt;br /&gt;&lt;pre name="code" class="Delphi"&gt;interface&lt;br /&gt;&lt;br /&gt;uses&lt;br /&gt;ExtCtrls, Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,&lt;br /&gt;Dialogs, StdCtrls;&lt;br /&gt;&lt;br /&gt;type&lt;br /&gt;TThresholdForm = class(TForm)&lt;br /&gt;LowScrollBar: TScrollBar;&lt;br /&gt;HighScrollBar: TScrollBar;&lt;br /&gt;InvertCheckBox: TCheckBox;&lt;br /&gt;ThresholdInsideCheckBox: TCheckBox;&lt;br /&gt;Label1: TLabel;&lt;br /&gt;Label2: TLabel;&lt;br /&gt;OKButton: TButton;&lt;br /&gt;CancelButton: TButton;&lt;br /&gt;private&lt;br /&gt;TemporaryImage:TImage;&lt;br /&gt;OriginalImage:TImage;&lt;br /&gt;Applied:boolean;&lt;br /&gt;public&lt;br /&gt;procedure SetThreshold(Image: TImage);&lt;br /&gt;{ Public declarations }&lt;br /&gt;end;&lt;/pre&gt;The Implementation&lt;br /&gt;(to be continued)&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5740833303868793836-98456170585006401?l=imageprocessingindelphi.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://imageprocessingindelphi.blogspot.com/feeds/98456170585006401/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5740833303868793836&amp;postID=98456170585006401' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5740833303868793836/posts/default/98456170585006401'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5740833303868793836/posts/default/98456170585006401'/><link rel='alternate' type='text/html' href='http://imageprocessingindelphi.blogspot.com/2008/08/threshold-below-threshold-above-and.html' title='Threshold Below, Threshold Above, and Threshold Inside Implementation in Delphi'/><author><name>techtalk</name><uri>http://www.blogger.com/profile/06105126060926155997</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5740833303868793836.post-3584072849986863566</id><published>2008-08-09T16:50:00.000-07:00</published><updated>2008-08-09T21:13:50.863-07:00</updated><title type='text'>Thresholding</title><content type='html'>&lt;div style="text-align: justify;"&gt;Thresholding in image processing is used to convert a gray scale image to binary format, where only two values are possible for the pixel, zero ore one. Thresholding can be viewed as the simplest method of image segmentation. Thresholding is common step in an image analysis, where we need to differentiate the pixel area by two different brightness area, for example between object and the background.&lt;br /&gt;&lt;p&gt;&lt;b&gt;&lt;/b&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;&lt;b&gt;Thresholding&lt;/b&gt; is the simplest method of image segmentation.  From a gray scale image, thresholding can be used to create binary image &lt;a href="http://en.wikipedia.org/wiki/Thresholding_%28image_processing%29#Shapiro2001" title=""&gt;(Shapiro, et al 2001:83)&lt;/a&gt;.&lt;/p&gt; During the thresholding process, individual pixels in an image are marked as “object” pixels if their value is greater than some threshold value (assuming an object to be brighter than the background) and as “background” pixels otherwise. This convention is known as &lt;i&gt;threshold above&lt;/i&gt;. Variants include &lt;i&gt;threshold below&lt;/i&gt;, which is opposite of threshold above; &lt;i&gt;threshold inside&lt;/i&gt;, where a pixel is labeled "object" if its value is between two thresholds; and &lt;i&gt;threshold outside&lt;/i&gt;, which is the opposite of threshold inside &lt;a href="http://en.wikipedia.org/wiki/Thresholding_%28image_processing%29#Shapiro2001" title=""&gt;(Shapiro, et al 2001:83)&lt;/a&gt;.&lt;/blockquote&gt;The most important key in the thresholding process is the threshold point. Manually, the threshold pint can be visually judged by trial and error, adjusting the value is you don't get the desired background-object separation.&lt;br /&gt;&lt;br /&gt;For Automatic thresholding, many methods have been implemented in many research. You can simply use the mean or median value, or you can &lt;a href="http://imageprocessingindelphi.blogspot.com/2008/07/purpose-of-image-histogram-analysis.html"&gt;analyze the histogram&lt;/a&gt; and find a valley for the threshold value.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5740833303868793836-3584072849986863566?l=imageprocessingindelphi.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://imageprocessingindelphi.blogspot.com/feeds/3584072849986863566/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5740833303868793836&amp;postID=3584072849986863566' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5740833303868793836/posts/default/3584072849986863566'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5740833303868793836/posts/default/3584072849986863566'/><link rel='alternate' type='text/html' href='http://imageprocessingindelphi.blogspot.com/2008/08/thresholding.html' title='Thresholding'/><author><name>techtalk</name><uri>http://www.blogger.com/profile/06105126060926155997</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5740833303868793836.post-1991692971779720027</id><published>2008-08-07T07:32:00.000-07:00</published><updated>2008-08-07T08:43:32.277-07:00</updated><title type='text'>RGB to Gray Scale Conversion Using Delphi</title><content type='html'>&lt;div style="text-align: justify;"&gt;We can code an RGB to Gray scale conversion directly in the main unit of our &lt;a href="http://imageprocessingindelphi.blogspot.com/2008/08/color-inversion-processing-in-delphi.html"&gt;color inversion&lt;/a&gt; project. It is easy, as easy as our color inversion project.&lt;br /&gt;&lt;/div&gt;&lt;ol&gt;&lt;li style="text-align: justify;"&gt;Open our previous &lt;a href="http://imageprocessingindelphi.blogspot.com/2008/08/color-inversion-processing-in-delphi.html"&gt;color inversion&lt;/a&gt; project.&lt;/li&gt;&lt;li style="text-align: justify;"&gt;Double click the main menu component, and add a menu item 'Convert to Gray Scale' under Image menu (see figure 1).&lt;/li&gt;&lt;li style="text-align: justify;"&gt;Double click on the menu item, and you'll be directed to the event handler, edit as shown below:&lt;br /&gt;&lt;pre name="code" class="Delphi"&gt;&lt;br /&gt;procedure TMainForm.ConverttoGrayScale1Click(Sender: TObject);&lt;br /&gt;var&lt;br /&gt;i,j:integer;&lt;br /&gt;ptr:PByteArray;&lt;br /&gt;begin&lt;br /&gt;try&lt;br /&gt; ImageForm:=TImageForm(ActiveMDIChild);&lt;br /&gt; for i:=0 to (ImageForm.Image1.Height-1) do&lt;br /&gt; begin&lt;br /&gt;   ptr:=ImageForm.Image1.Picture.Bitmap.ScanLine[i];&lt;br /&gt;   for j:=0 to (ImageForm.Image1.Width-1) do&lt;br /&gt;   begin&lt;br /&gt;     if ImageForm.Image1.Picture.Bitmap.PixelFormat&lt;br /&gt;       =pf24bit then&lt;br /&gt;     begin&lt;br /&gt;       ptr[3*j]:=round(0.114* ptr[3*j]&lt;br /&gt;         +0.587*ptr[3*j+1] + 0.299*ptr[3*j+2]);&lt;br /&gt;       ptr[3*j+1]:=ptr[3*j];&lt;br /&gt;       ptr[3*j+2]:=ptr[3*j];&lt;br /&gt;     end;&lt;br /&gt;   end;&lt;br /&gt;   ImageForm.Image1.Refresh;&lt;br /&gt; end;&lt;br /&gt; except&lt;br /&gt;   ShowMessage('Cannot complete the operation');&lt;br /&gt; end&lt;br /&gt;end;&lt;/pre&gt;&lt;/li&gt;&lt;li style="text-align: justify;"&gt;Save all files, and now you can compile/run the project. The execution looks like shown in figure 2.&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_sU93Gokt0UY/SJsNBE5WdZI/AAAAAAAAAF0/v08j2BmYPiw/s1600-h/rgb_to_gray_menu.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://4.bp.blogspot.com/_sU93Gokt0UY/SJsNBE5WdZI/AAAAAAAAAF0/v08j2BmYPiw/s400/rgb_to_gray_menu.gif" alt="" id="BLOGGER_PHOTO_ID_5231789704266282386" border="0" /&gt;&lt;/a&gt;&lt;span style="font-weight: bold;"&gt;Figure 1. RGB to Gray Scale Conversion Menu&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_sU93Gokt0UY/SJsVK9swbaI/AAAAAAAAAF8/OfZ6GkYEziQ/s1600-h/rgb_to_gray.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://1.bp.blogspot.com/_sU93Gokt0UY/SJsVK9swbaI/AAAAAAAAAF8/OfZ6GkYEziQ/s400/rgb_to_gray.gif" alt="" id="BLOGGER_PHOTO_ID_5231798670226124194" border="0" /&gt;&lt;/a&gt;&lt;span style="font-weight: bold;"&gt;Figure 2. RGB to Gray Scale Conversion&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Source Code Download&lt;/span&gt;&lt;br /&gt;You can download the &lt;a href="http://www.mediafire.com/?w9j4wk9mmky"&gt;Delphi 7 source code here&lt;/a&gt;, and the &lt;a href="http://www.mediafire.com/?zshd9rv2bxk"&gt;Turbo Delphi Explorer source code here&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5740833303868793836-1991692971779720027?l=imageprocessingindelphi.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://imageprocessingindelphi.blogspot.com/feeds/1991692971779720027/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5740833303868793836&amp;postID=1991692971779720027' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5740833303868793836/posts/default/1991692971779720027'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5740833303868793836/posts/default/1991692971779720027'/><link rel='alternate' type='text/html' href='http://imageprocessingindelphi.blogspot.com/2008/08/rgb-to-gray-scale-conversion-using.html' title='RGB to Gray Scale Conversion Using Delphi'/><author><name>techtalk</name><uri>http://www.blogger.com/profile/06105126060926155997</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_sU93Gokt0UY/SJsNBE5WdZI/AAAAAAAAAF0/v08j2BmYPiw/s72-c/rgb_to_gray_menu.gif' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5740833303868793836.post-3132742561432533967</id><published>2008-08-07T06:33:00.000-07:00</published><updated>2008-08-09T16:48:35.871-07:00</updated><title type='text'>RGB to Gray Scale Conversion</title><content type='html'>&lt;div style="text-align: justify;"&gt;Intensity of an image is the average of the three color elements, so the gray scale image that represent the original color image can be computed as:&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-style: italic;"&gt;I0=(Ri+Gi+Bi)/3&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Io is the output intensity, Ri, Gi, and Bi are the red, green, and the blue element intensity. The formula for more realistic result is by adding different weight for each R,G, and B element. We normally percept green color brighter that red color, and red color brighter than blue color. That's why we usually set the weight higher for red and higher for green.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-style: italic;"&gt;Io=(0.299Ri + 0.587Gi + 0.144Bi)/3&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Actually there is no absolute reference for each weight values because it depends on the display technology that might change in the future. The above formula is standardized by NTSC (National Television System Committee), and its usage is common in computer imaging.&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5740833303868793836-3132742561432533967?l=imageprocessingindelphi.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://imageprocessingindelphi.blogspot.com/feeds/3132742561432533967/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5740833303868793836&amp;postID=3132742561432533967' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5740833303868793836/posts/default/3132742561432533967'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5740833303868793836/posts/default/3132742561432533967'/><link rel='alternate' type='text/html' href='http://imageprocessingindelphi.blogspot.com/2008/08/rgb-to-gray-scale-conversion.html' title='RGB to Gray Scale Conversion'/><author><name>techtalk</name><uri>http://www.blogger.com/profile/06105126060926155997</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5740833303868793836.post-3429177661834113608</id><published>2008-08-07T05:17:00.000-07:00</published><updated>2008-08-07T06:23:51.485-07:00</updated><title type='text'>Color Inversion Processing in Delphi</title><content type='html'>&lt;div style="text-align: justify;"&gt;To implement color inversion is very easy, we don't need a special form for user interface. We can directly implement the code in the main unit.&lt;br /&gt;&lt;/div&gt;&lt;ol&gt;&lt;li style="text-align: justify;"&gt;Open our previous &lt;a href="http://imageprocessingindelphi.blogspot.com/2008/08/coding-contrast-enhancement-in-delphi.html"&gt;contrast enhancement&lt;/a&gt; project.&lt;/li&gt;&lt;li style="text-align: justify;"&gt;Double click the main menu component, and add a menu item 'Invert' under Image menu (see figure 1).&lt;/li&gt;&lt;li style="text-align: justify;"&gt;Double click on the menu item, and you'll be directed to the event handler, edit as shown below:&lt;br /&gt;&lt;pre name="code" class="Delphi"&gt;&lt;br /&gt;procedure TMainForm.Invert1Click(Sender: TObject);&lt;br /&gt;var&lt;br /&gt;i,j:integer;&lt;br /&gt;ptr:PByteArray;&lt;br /&gt;begin&lt;br /&gt;try&lt;br /&gt; ImageForm:=TImageForm(ActiveMDIChild);&lt;br /&gt; for i:=0 to (ImageForm.Image1.Height-1) do&lt;br /&gt; begin&lt;br /&gt;   ptr:=ImageForm.Image1.Picture.Bitmap.ScanLine[i];&lt;br /&gt;   for j:=0 to (ImageForm.Image1.Width-1) do&lt;br /&gt;   begin&lt;br /&gt;     if ImageForm.Image1.Picture.Bitmap.PixelFormat&lt;br /&gt;       =pf8bit then ptr[j]:=255-ptr[j];&lt;br /&gt;     if ImageForm.Image1.Picture.Bitmap.PixelFormat&lt;br /&gt;       =pf24bit then&lt;br /&gt;     begin&lt;br /&gt;       ptr[3*j]:=255-ptr[3*j];&lt;br /&gt;       ptr[3*j+1]:=255-ptr[3*j+1];&lt;br /&gt;       ptr[3*j+2]:=255-ptr[3*j+2];&lt;br /&gt;     end;&lt;br /&gt;   end;&lt;br /&gt;   ImageForm.Image1.Refresh;&lt;br /&gt; end;&lt;br /&gt; except&lt;br /&gt;   ShowMessage('Cannot complete the operation');&lt;br /&gt; end&lt;br /&gt;end; &lt;/pre&gt;&lt;/li&gt;&lt;li&gt;Save all files and now you can compile and run the executable. The execution is shown in Figure 2 and Figure 3.&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_sU93Gokt0UY/SJrqgyWDQcI/AAAAAAAAAFc/3eZOX_6Z2mY/s1600-h/invert_menu.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://3.bp.blogspot.com/_sU93Gokt0UY/SJrqgyWDQcI/AAAAAAAAAFc/3eZOX_6Z2mY/s400/invert_menu.gif" alt="" id="BLOGGER_PHOTO_ID_5231751766135226818" border="0" /&gt;&lt;/a&gt;&lt;span style="font-weight: bold;"&gt;Figure 1. Invert Menu&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_sU93Gokt0UY/SJrylaMFO-I/AAAAAAAAAFk/pQqc8wLHrTM/s1600-h/monochrome_invert.JPG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://3.bp.blogspot.com/_sU93Gokt0UY/SJrylaMFO-I/AAAAAAAAAFk/pQqc8wLHrTM/s400/monochrome_invert.JPG" alt="" id="BLOGGER_PHOTO_ID_5231760641643330530" border="0" /&gt;&lt;/a&gt;&lt;span style="font-weight: bold;"&gt;Figure 2. Color Inversion of Monochrome Image&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_sU93Gokt0UY/SJrzArIBSGI/AAAAAAAAAFs/oOE3Jchd3zQ/s1600-h/color_invert.JPG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://4.bp.blogspot.com/_sU93Gokt0UY/SJrzArIBSGI/AAAAAAAAAFs/oOE3Jchd3zQ/s400/color_invert.JPG" alt="" id="BLOGGER_PHOTO_ID_5231761110046165090" border="0" /&gt;&lt;/a&gt;&lt;span style="font-weight: bold;"&gt;Figure 3. Color Inversion on True Color Picture&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Source Code Download&lt;/span&gt;&lt;br /&gt;You can &lt;a href="http://www.mediafire.com/?3hlnmxx4tzs"&gt;download the source code for Delphi 7 here&lt;/a&gt; and for &lt;a href="http://www.mediafire.com/?yepxve3tdb9"&gt;Turbo Delphi Explorer&lt;/a&gt; here.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5740833303868793836-3429177661834113608?l=imageprocessingindelphi.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://imageprocessingindelphi.blogspot.com/feeds/3429177661834113608/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5740833303868793836&amp;postID=3429177661834113608' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5740833303868793836/posts/default/3429177661834113608'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5740833303868793836/posts/default/3429177661834113608'/><link rel='alternate' type='text/html' href='http://imageprocessingindelphi.blogspot.com/2008/08/color-inversion-processing-in-delphi.html' title='Color Inversion Processing in Delphi'/><author><name>techtalk</name><uri>http://www.blogger.com/profile/06105126060926155997</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_sU93Gokt0UY/SJrqgyWDQcI/AAAAAAAAAFc/3eZOX_6Z2mY/s72-c/invert_menu.gif' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5740833303868793836.post-8519986670198633248</id><published>2008-08-07T04:53:00.000-07:00</published><updated>2008-08-07T05:14:44.714-07:00</updated><title type='text'>Color Inversion</title><content type='html'>&lt;div style="text-align: justify;"&gt;Color inversion in digital image processing is done by inverting all color element. For monochrome image, the dark pixel in the original image will be the bright pixel in the inversed image. The effect show horizontal mirroring in the histogram.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_sU93Gokt0UY/SJrmAHgqLsI/AAAAAAAAAFU/GwTWcLMckUk/s1600-h/inversed_histogram.GIF"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://3.bp.blogspot.com/_sU93Gokt0UY/SJrmAHgqLsI/AAAAAAAAAFU/GwTWcLMckUk/s400/inversed_histogram.GIF" alt="" id="BLOGGER_PHOTO_ID_5231746806834671298" border="0" /&gt;&lt;/a&gt;The GST function is simple, the Intensity of the output Io=Imax-Ii, where Imax is the maximum Intensity value, and Ii is the input pixel's intensity. The maximum intensity value is 255 for 8bit monochrome or 24bit true color. For 24 bit true color, each RGB elements is operated independently.&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5740833303868793836-8519986670198633248?l=imageprocessingindelphi.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://imageprocessingindelphi.blogspot.com/feeds/8519986670198633248/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5740833303868793836&amp;postID=8519986670198633248' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5740833303868793836/posts/default/8519986670198633248'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5740833303868793836/posts/default/8519986670198633248'/><link rel='alternate' type='text/html' href='http://imageprocessingindelphi.blogspot.com/2008/08/color-inversion.html' title='Color Inversion'/><author><name>techtalk</name><uri>http://www.blogger.com/profile/06105126060926155997</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_sU93Gokt0UY/SJrmAHgqLsI/AAAAAAAAAFU/GwTWcLMckUk/s72-c/inversed_histogram.GIF' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5740833303868793836.post-3611824409419403097</id><published>2008-08-03T00:23:00.000-07:00</published><updated>2008-08-05T02:02:44.049-07:00</updated><title type='text'>Coding Contrast Enhancement in Delphi</title><content type='html'>&lt;span style="font-weight: bold;"&gt;Designing the GUI and The Processing Algorithm&lt;/span&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;To make our &lt;a href="http://imageprocessingindelphi.blogspot.com/2008/08/contrast-enhancement.html"&gt;contrast enhancement&lt;/a&gt; processing, we need to design the graphical user interface (GUI)  first. The GUI is similar with our previous &lt;a href="http://imageprocessingindelphi.blogspot.com/2008/07/brightness-manipulation-in-delphi.html"&gt;brightness modification&lt;/a&gt; user interface. The following steps explains how to make it:&lt;br /&gt;&lt;/div&gt;&lt;ol style="text-align: justify;"&gt;&lt;li&gt;Open (or download first) our previous  &lt;a href="http://imageprocessingindelphi.blogspot.com/2008/07/brightness-manipulation-in-delphi.html"&gt;brightness modification&lt;/a&gt;  project.&lt;/li&gt;&lt;li&gt;Create a new form (File-&gt;New-&gt;Form).&lt;/li&gt;&lt;li&gt;Change the name property to ContrastForm, change the Caption property to 'Contrast'. Set the FormStyle property to fsMDIChild. Resize the form to fit the main form (parent form).&lt;/li&gt;&lt;li&gt;On the Object Inspector, click on Events tab, and double click in the OnClose event. You'll be directed to the event handler, and assign the Action variable with caFree between &lt;span style="font-weight: bold;"&gt;begin &lt;/span&gt;and &lt;span style="font-weight: bold;"&gt;end&lt;/span&gt;&lt;br /&gt;&lt;pre name="code" class="Delphi"&gt;procedure TContrastForm.FormClose(Sender: TObject;&lt;br /&gt;var Action: TCloseAction);&lt;br /&gt;begin&lt;br /&gt;Action:=caFree;&lt;br /&gt;end;&lt;/pre&gt;&lt;/li&gt;&lt;li&gt;Add two scroll bar components (from the standard component pallet) to the form. Change the Name property to CenterScrollBar and ContrastScrollBar. Set the Minimum property of CenterScrollBar to 0 and the Maximum to 255. Set the minimum property of ContrastScrollBar to -100 and the maximum to 100. Set the position of CenterScrollBar to 127, set the position of ContrastScrollBar to 0.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Place two label components (from the standar component pallet) to the form, set the layout to associate each label to each scroll bar. Change the Label's caption to 'Center' and 'Contrast' accordingly (see Figure 1).&lt;/li&gt;&lt;li&gt;Add two buttons (from standard component pallet), change their caption to OK and Cancel, and set their name to OKButton and CancelButton accordingly.&lt;/li&gt;&lt;li&gt;Save the unit as ContrastUnit (using menu File-&gt;Save As).&lt;/li&gt;&lt;li&gt;Go to Project-&gt;Options-&gt;Form, point to ContrastForm to select, and press the &gt; button, so the ContrastForm will move to Available forms box, then press OK.&lt;/li&gt;&lt;/ol&gt;&lt;div style="text-align: justify;"&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_sU93Gokt0UY/SJWX52b56zI/AAAAAAAAADE/FDHO6mOTk3o/s1600-h/contrast_form.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://4.bp.blogspot.com/_sU93Gokt0UY/SJWX52b56zI/AAAAAAAAADE/FDHO6mOTk3o/s320/contrast_form.gif" alt="" id="BLOGGER_PHOTO_ID_5230253562381593394" border="0" /&gt;&lt;/a&gt;&lt;span style="font-weight: bold;"&gt;Figure 1. Contrast GUI Form&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;To modify the image, it's common to backup the original image, so we can do a cancel operation after displaying the change on the original image form. To do this, we have to provide TImage object in the form to temporarily store the image. A procedure (SetContrast) to associate the image input to the brightness form is also needed.&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Edit the BrightnessForm abstraction to provide TImage (TemporaryImage and OriginalImage) object and the SetBrightness procedure. A boolean flag (Applied) is also needed to mark whether a Cancel or OK button has been pressed. Add ExtCtrls under &lt;span style="font-weight: bold;"&gt;uses &lt;/span&gt;in the &lt;span style="font-weight: bold;"&gt;Interface &lt;/span&gt;section because we're gonna use TImage component.  Edit as shown below:&lt;br /&gt;&lt;pre name="code" class="Delphi"&gt;type&lt;br /&gt;TContrastForm = class(TForm)&lt;br /&gt;CenterScrollbar: TScrollBar;&lt;br /&gt;ContrastScrollBar: TScrollBar;&lt;br /&gt;Label1: TLabel;&lt;br /&gt;Label2: TLabel;&lt;br /&gt;OKButton: TButton;&lt;br /&gt;CancelButton: TButton;&lt;br /&gt;procedure FormClose(Sender: TObject; var Action: TCloseAction);&lt;br /&gt;private&lt;br /&gt;{ Private declarations }&lt;br /&gt;TemporaryImage:TImage;&lt;br /&gt;OriginalImage:TImage;&lt;br /&gt;Applied:boolean;&lt;br /&gt;public&lt;br /&gt;{ Public declarations }&lt;br /&gt;procedure SetContrast(Image: TImage);&lt;br /&gt;end;&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;li&gt;Write the SetContrast procedure definition in the implementation section:&lt;br /&gt;&lt;pre name="code" class="Delphi"&gt;procedure TContrastForm.SetContrast(Image: TImage);&lt;br /&gt;begin&lt;br /&gt;try&lt;br /&gt;begin&lt;br /&gt;TemporaryImage:=Image;&lt;br /&gt;TemporaryImage.Picture.Bitmap.PixelFormat:=pf24bit;&lt;br /&gt;OriginalImage:=TImage.Create(self);&lt;br /&gt;OriginalImage.Picture.Bitmap.Assign(Image.Picture.Bitmap);&lt;br /&gt;end;&lt;br /&gt;except&lt;br /&gt;begin&lt;br /&gt;Free; //free the contrast form&lt;br /&gt;ShowMessage('Cannot complete the operation');&lt;br /&gt;end;&lt;br /&gt;end;&lt;br /&gt;end;&lt;/pre&gt;&lt;/li&gt;&lt;li&gt;Double click the CenterScrollBar component, the you'll be directed to its event handler, edit as shown below&lt;br /&gt;&lt;pre name="code" class="Delphi"&gt;procedure TContrastForm.CenterScrollbarChange(Sender: TObject);&lt;br /&gt;var&lt;br /&gt;i,j:Integer;&lt;br /&gt;temp:real;&lt;br /&gt;pixelPointer:PByteArray;&lt;br /&gt;originalPixelPointer:PByteArray;&lt;br /&gt;begin&lt;br /&gt;try&lt;br /&gt;begin&lt;br /&gt;if TemporaryImage.Picture.Bitmap.PixelFormat=pf8bit then&lt;br /&gt;for i:=0 to TemporaryImage.Picture.Height-1 do&lt;br /&gt;begin&lt;br /&gt;pixelPointer:=TemporaryImage.Picture.Bitmap.ScanLine[i];&lt;br /&gt;originalPixelPointer:=OriginalImage.Picture.Bitmap.ScanLine[i];&lt;br /&gt;for j:=0 to TemporaryImage.Picture.Width-1 do&lt;br /&gt;begin&lt;br /&gt;temp:=((originalPixelPointer[j]-CenterScrollBAr.Position)&lt;br /&gt;*exp(ContrastScrollBar.Position/50))&lt;br /&gt;+ CenterScrollBar.Position;&lt;br /&gt;if temp&lt;0&gt;255 then temp:=255;&lt;br /&gt;pixelPointer[j]:=round(temp);&lt;br /&gt;end;&lt;br /&gt;end;&lt;br /&gt;if TemporaryImage.Picture.Bitmap.PixelFormat=pf24bit then&lt;br /&gt;for i:=0 to TemporaryImage.Picture.Height-1 do&lt;br /&gt;begin&lt;br /&gt;pixelPointer:=TemporaryImage.Picture.Bitmap.ScanLine[i];&lt;br /&gt;originalPixelPointer:=OriginalImage.Picture.Bitmap.ScanLine[i];&lt;br /&gt;for j:=0 to TemporaryImage.Picture.Width-1 do&lt;br /&gt;begin&lt;br /&gt;temp:=((originalPixelPointer[3*j]-CenterScrollBAr.Position)&lt;br /&gt;*exp(ContrastScrollBar.Position/50))&lt;br /&gt;+ CenterScrollBar.Position;&lt;br /&gt;if temp&lt;0&gt;255 then temp:=255;&lt;br /&gt;pixelPointer[3*j]:=round(temp);&lt;br /&gt;temp:=((originalPixelPointer[3*j+1]-CenterScrollBAr.Position)&lt;br /&gt;*exp(ContrastScrollBar.Position/50))&lt;br /&gt;+ CenterScrollBar.Position;&lt;br /&gt;if temp&lt;0&gt;255 then temp:=255;&lt;br /&gt;pixelPointer[3*j+2]:=round(temp);&lt;br /&gt;temp:=((originalPixelPointer[3*j+2]-CenterScrollBAr.Position)&lt;br /&gt;*exp(ContrastScrollBar.Position/50))&lt;br /&gt;+ CenterScrollBar.Position;&lt;br /&gt;if temp&lt;0&gt;255 then temp:=255;&lt;br /&gt;pixelPointer[3*j+2]:=round(temp);&lt;br /&gt;end;&lt;br /&gt;end;&lt;br /&gt;TemporaryImage.Refresh;&lt;br /&gt;end;&lt;br /&gt;except&lt;br /&gt;begin&lt;br /&gt;Free;&lt;br /&gt;ShowMessage('Cannot complete the operation');&lt;br /&gt;end;&lt;br /&gt;end;&lt;br /&gt;end;&lt;/pre&gt;&lt;br /&gt;In the code shown above, you can see the contrast gain is computed as exp(ContrastScrollBar.Position/50), with this formula, when the scroll bar position is zero (the default), the gain will be exp(0/50)=1, and at maximum the contrast gain will be exp(100/50)=100, and at the minimum the contrast gain will be exp(-100/50)=1/100.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;On the ContrastForm, double clicks the OKButton component, you'll be directed to its event handler, then edit as shown below:&lt;br /&gt;&lt;pre name="code" class="Delphi"&gt;procedure TContrastForm.OKButtonClick(Sender: TObject);&lt;br /&gt;begin&lt;br /&gt;Applied:=true;&lt;br /&gt;Close();&lt;br /&gt;end;&lt;/pre&gt;&lt;/li&gt;&lt;li&gt;Double click the CancelButton component in the ContrastForm, and you'll be directed to its event handler, edit as shown below:&lt;br /&gt;&lt;pre name="code" class="Delphi"&gt; procedure TContrastForm.CancelButtonClick(Sender: TObject);&lt;br /&gt;begin&lt;br /&gt;Applied:=false;&lt;br /&gt;Close();&lt;br /&gt;end;&lt;/pre&gt;&lt;/li&gt;&lt;li&gt;To implement the decision whether the image on the source form will be modified or reverted to the original bitmap, edit the ContrastForm's OnClose event handler as shown below:&lt;br /&gt;&lt;pre name="code" class="Delphi"&gt;procedure TContrastForm.FormClose(Sender: TObject; var Action: TCloseAction);&lt;br /&gt;begin&lt;br /&gt;if Applied=false then&lt;br /&gt;TemporaryImage.Picture.Bitmap.Assign(&lt;br /&gt;OriginalImage.Picture.Bitmap);&lt;br /&gt;Action:=caFree;&lt;br /&gt;end;&lt;/pre&gt;&lt;/li&gt;&lt;/ol&gt;&lt;span style="font-weight: bold;"&gt;Calling the GUI Module from The Main Application&lt;/span&gt;&lt;br /&gt;To show the contrast enhancement interface and to connect the active image form to the contrast GUI, we need to add a new item in the main menu. Double click the main menu component in the main form, and add a Contrast menu item under menu Image (Image-&gt;Contrast, see Figure 2.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_sU93Gokt0UY/SJf-gtRVP4I/AAAAAAAAADM/Oo_Kpxh408k/s1600-h/contrast_menu.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://1.bp.blogspot.com/_sU93Gokt0UY/SJf-gtRVP4I/AAAAAAAAADM/Oo_Kpxh408k/s320/contrast_menu.gif" alt="" id="BLOGGER_PHOTO_ID_5230929330075680642" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-weight: bold;"&gt;Figure 2. Contrast Menu Item&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Write the event handler for the menu as shown below:&lt;br /&gt;&lt;pre name="code" class="Delphi"&gt;procedure TMainForm.Contrast1Click(Sender: TObject);&lt;br /&gt;begin&lt;br /&gt;if ImageForm&lt;&gt;nil then&lt;br /&gt;begin&lt;br /&gt;ImageForm:=TImageForm(ActiveMDIChild);&lt;br /&gt;try&lt;br /&gt;begin&lt;br /&gt;Application.CreateForm(TContrastForm,ContrastForm);&lt;br /&gt;ContrastForm.SetContrast(ImageForm.Image1);&lt;br /&gt;end;&lt;br /&gt;except&lt;br /&gt;ContrastForm.Free;&lt;br /&gt;ShowMessage('Cannot complete the operation');&lt;br /&gt;end;&lt;br /&gt;end;&lt;br /&gt;end;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_sU93Gokt0UY/SJf-8IKDWpI/AAAAAAAAADU/qbWJansIojk/s1600-h/contrast_delphi_executable.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://1.bp.blogspot.com/_sU93Gokt0UY/SJf-8IKDWpI/AAAAAAAAADU/qbWJansIojk/s320/contrast_delphi_executable.jpg" alt="" id="BLOGGER_PHOTO_ID_5230929801149373074" border="0" /&gt;&lt;/a&gt;&lt;span style="font-weight: bold;"&gt;Figure 3. Contrast Processing Execution&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;Don't forget to add ContrastUnit under the uses in the MainUnit's implementation. Use menu File-&gt;Use Unit (Alt+F11). Now you can save, compile and run the executable. The execution look like figure 3.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Source Code Download&lt;/span&gt;&lt;br /&gt;The source code &lt;a href="http://www.mediafire.com/?nbpw2o4ndzz"&gt;can be downloaded here for Delphi 7 project&lt;/a&gt;, and &lt;a href="http://www.mediafire.com/?yt46hbrxp0z"&gt;here for the Turbo Delphi Explorer source code&lt;/a&gt;. Besides contains new source codes for contrast enhancement, if you compare to our previous &lt;a href="http://imageprocessingindelphi.blogspot.com/2008/07/brightness-manipulation-in-delphi.html"&gt;brightness modification project's source codes&lt;/a&gt;, you'll see that in the codes for the brightness manipulation codes has also been updated to accommodate both two different image formats, pf8bit (8 bit monochrom/gray sacle) and pf24bit (true color). When applied to a monochrome image, sliding one scroll bar will move other two scroll bars to reflect that monochrome image doesn't have any separate RGB components.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5740833303868793836-3611824409419403097?l=imageprocessingindelphi.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://imageprocessingindelphi.blogspot.com/feeds/3611824409419403097/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5740833303868793836&amp;postID=3611824409419403097' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5740833303868793836/posts/default/3611824409419403097'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5740833303868793836/posts/default/3611824409419403097'/><link rel='alternate' type='text/html' href='http://imageprocessingindelphi.blogspot.com/2008/08/coding-contrast-enhancement-in-delphi.html' title='Coding Contrast Enhancement in Delphi'/><author><name>techtalk</name><uri>http://www.blogger.com/profile/06105126060926155997</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_sU93Gokt0UY/SJWX52b56zI/AAAAAAAAADE/FDHO6mOTk3o/s72-c/contrast_form.gif' height='72' width='72'/><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5740833303868793836.post-4217804298905647875</id><published>2008-08-02T17:06:00.000-07:00</published><updated>2008-08-03T00:21:51.001-07:00</updated><title type='text'>Contrast Enhancement</title><content type='html'>&lt;div style="text-align: justify;"&gt;&lt;div style="text-align: justify;"&gt;Contrast in an image is the difference between pixels values. Without contrast we can't see anything because everything will be white or black, or just gray. If an image has a low contrast, it means that different objects in the image have low luminosity difference, and and it'll be difficult to separate them in our perception. Contrast enhancement will be helpful in increasing the visibility of an image. Figure 1 show two images with different contrast and their histogram.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_sU93Gokt0UY/SJVZXXaldNI/AAAAAAAAAC8/ioBGlEjX_P0/s1600-h/contrast.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://2.bp.blogspot.com/_sU93Gokt0UY/SJVZXXaldNI/AAAAAAAAAC8/ioBGlEjX_P0/s320/contrast.jpg" alt="" id="BLOGGER_PHOTO_ID_5230184800218084562" border="0" /&gt;&lt;/a&gt;&lt;span style="font-weight: bold;"&gt;Figure 1. Histograms of An Image Before Contrast Enhancement (upper image) and After Contrast Enhancement (lower image)&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Contrast enhancement can be done using various gray scale transformation (GST) formulas. The following is one of contrast enhancement GST formula:&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-style: italic;"&gt;Po=G(Pi-C)+C&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;Which G is contrast gain, and C is the center for contrasting reference. At point C the pixel value is not modified, at above C point the pixels values is increased, and below C they're decreased.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5740833303868793836-4217804298905647875?l=imageprocessingindelphi.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://imageprocessingindelphi.blogspot.com/feeds/4217804298905647875/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5740833303868793836&amp;postID=4217804298905647875' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5740833303868793836/posts/default/4217804298905647875'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5740833303868793836/posts/default/4217804298905647875'/><link rel='alternate' type='text/html' href='http://imageprocessingindelphi.blogspot.com/2008/08/contrast-enhancement.html' title='Contrast Enhancement'/><author><name>techtalk</name><uri>http://www.blogger.com/profile/06105126060926155997</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_sU93Gokt0UY/SJVZXXaldNI/AAAAAAAAAC8/ioBGlEjX_P0/s72-c/contrast.jpg' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5740833303868793836.post-2435418948520070377</id><published>2008-07-29T19:25:00.000-07:00</published><updated>2008-08-03T08:35:06.756-07:00</updated><title type='text'>Brightness Manipulation in Delphi</title><content type='html'>&lt;div style="text-align: justify;"&gt;To manipulate an image's brightness is easy, first we can make the graphical user interface (GUI) to ease the manipulation. The GUI consist of a form with three sliding bar (TScrollBar). Each scroll bar is used to adjust the brightness constant for each color element.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;ol&gt;&lt;li&gt;Open our previous &lt;a href="http://imageprocessingindelphi.blogspot.com/2008/07/computing-and-displaying-image.html"&gt;image   histogram&lt;/a&gt; project (you can download the source code &lt;a href="http://imageprocessingindelphi.blogspot.com/2008/07/computing-and-displaying-image.html"&gt;there&lt;/a&gt;   if you don't have it).&lt;/li&gt;&lt;li&gt;Create a new form (File-&gt;New-&gt;Form).&lt;/li&gt;&lt;li&gt;Change  the name property to BrightnessForm, change the Caption property to 'Brightness'.  Set the FormStyle property to fsMDIChild. Resize the form to fit the main form (parent form).&lt;/li&gt;&lt;li&gt;On the Object Inspector, click on Events tab, and double click in the OnClose event. You'll be directed to the event handler, and assign the Action variable with caFree between &lt;span style="font-weight: bold;"&gt;begin &lt;/span&gt;and &lt;span style="font-weight: bold;"&gt;end&lt;/span&gt;.&lt;br /&gt;&lt;pre name="code" class="Delphi"&gt;&lt;br /&gt;procedure TBrightnessForm.FormClose(Sender: TObject;&lt;br /&gt;var Action: TCloseAction);&lt;br /&gt;begin&lt;br /&gt;Action:=caFree;&lt;br /&gt;end;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Add three scroll bar components (from the standard component pallet) to the form. Change the Name property to RedScrollBar, GreenScrollBar, and BlueScrollBar. Set the minimum and maximum property of each scroll bar to -255 and 255.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Place three label components (from the standar component pallet) to the form, place the layout to associate each label to each scroll bar. Change the Label's caption to Red, Green, and Blue, to label the scroll bar functions (See Figure 1).&lt;/li&gt;&lt;li&gt;Add two buttons (from standard component pallet), change their caption to OK and Cancel, and set their name to OKButton and CancelButton accordingly.&lt;/li&gt;&lt;li&gt;Save the unit as BrightnessUnit (using menu File-&gt;Save As).&lt;/li&gt;&lt;li&gt;Go to Project-&gt;Options-&gt;Form, point to BrightnessForm to select, and press the &gt; button, so the BrightessForm will move to Available forms box, then press OK.&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_sU93Gokt0UY/SI_aqPWe5yI/AAAAAAAAACk/fAAo7VY1DGk/s1600-h/brightness_gui.GIF"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://4.bp.blogspot.com/_sU93Gokt0UY/SI_aqPWe5yI/AAAAAAAAACk/fAAo7VY1DGk/s320/brightness_gui.GIF" alt="" id="BLOGGER_PHOTO_ID_5228638111610627874" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-weight: bold;"&gt;Figure 1. Brightness Modification GUI&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;To modify the image, it's common to backup the original image, so we can do a cancel operation after displaying the change on the original image form. To do this, we have to provide TImage object in the form to temporarily store the image. A procedure (SetBrightness) to associate the image input to the brightness form is also needed.&lt;br /&gt;&lt;ol&gt;&lt;li&gt;Edit the BrightnessForm abstraction to provide TImage object and the SetBrightness procedure. Add ExtCtrls under &lt;span style="font-weight: bold;"&gt;uses &lt;/span&gt;in the &lt;span style="font-weight: bold;"&gt;Interface &lt;/span&gt;section because we're gonna use TImage component.&lt;br /&gt;&lt;pre name="code" class="Delphi"&gt;uses&lt;br /&gt;ExtCtrls, Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,Dialogs, StdCtrls&lt;br /&gt;&lt;br /&gt;type= class(TForm)&lt;br /&gt;TBrightnessForm = class(TForm)&lt;br /&gt;RedScrollBar: TScrollBar;&lt;br /&gt;GreenScrollBar: TScrollBar;&lt;br /&gt;BlueScrollBar: TScrollBar;&lt;br /&gt;Label1: TLabel;&lt;br /&gt;Label2: TLabel;&lt;br /&gt;Label3: TLabel;&lt;br /&gt;OKButton: TButton;&lt;br /&gt;CancelButton: TButton;&lt;br /&gt;procedure FormClose(Sender: TObject; var Action: TCloseAction);&lt;br /&gt;private&lt;br /&gt;{ Private declarations }&lt;br /&gt;TemporaryImage:TImage;&lt;br /&gt;OriginalImage:TImage;&lt;br /&gt;Applied:boolean;&lt;br /&gt;public&lt;br /&gt;{ Public declarations }&lt;br /&gt;procedure SetBrightness(Image: TImage);&lt;br /&gt;end;&lt;/pre&gt;&lt;/li&gt;&lt;li&gt;Write the SetBrightness procedure in the implementation section&lt;br /&gt;&lt;pre name="code" class="Delphi"&gt;procedure TBrightnessForm.SetBrightness(Image: TImage);&lt;br /&gt;begin&lt;br /&gt;try&lt;br /&gt;begin&lt;br /&gt;TemporaryImage:=Image;&lt;br /&gt;OriginalImage:=TImage.Create(self);&lt;br /&gt;OriginalImage.Picture.Bitmap.Assign(Image.Picture.Bitmap);&lt;br /&gt;end;&lt;br /&gt;except&lt;br /&gt;begin&lt;br /&gt;Free; //free the brightness form&lt;br /&gt;ShowMessage('Cannot complete the operation');&lt;br /&gt;end;&lt;br /&gt;end;&lt;br /&gt;end;&lt;/pre&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Double click the RedScrollBar component, the you'll be directed to its event handler, edit as shown below&lt;br /&gt;&lt;pre name="code" class="Delphi"&gt;&lt;br /&gt;procedure TBrightnessForm.RedScrollBarChange(Sender: TObject);&lt;br /&gt;var&lt;br /&gt;  i,j:Integer;&lt;br /&gt;  temp:integer;&lt;br /&gt;  pixelPointer:PByteArray;&lt;br /&gt;  originalPixelPointer:PByteArray;&lt;br /&gt;begin&lt;br /&gt;  try&lt;br /&gt;    begin&lt;br /&gt;      for i:=0 to TemporaryImage.Picture.Height-1 do&lt;br /&gt;      begin&lt;br /&gt;        pixelPointer:=TemporaryImage.Picture.Bitmap.ScanLine[i];&lt;br /&gt;        originalPixelPointer:=OriginalImage.Picture.Bitmap.ScanLine[i];&lt;br /&gt;        for j:=0 to TemporaryImage.Picture.Width-1 do&lt;br /&gt;        begin&lt;br /&gt;          temp:=originalPixelPointer[3*j+2]+ RedScrollBar.Position;&lt;br /&gt;          if temp&lt;0 then temp:=0;&lt;br /&gt;          if temp&gt;255 then temp:=255;&lt;br /&gt;          pixelPointer[3*j+2]:=temp;&lt;br /&gt;        end;&lt;br /&gt;      end;&lt;br /&gt;      TemporaryImage.Refresh;&lt;br /&gt;    end;&lt;br /&gt;  except&lt;br /&gt;    begin&lt;br /&gt;      Free;&lt;br /&gt;      ShowMessage('Cannot complete the operation');&lt;br /&gt;    end;&lt;br /&gt;  end;&lt;br /&gt;end;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Double click the GreenScrollBar component, the you'll be directed to its event handler, edit as shown below&lt;br /&gt;&lt;pre name="code" class="Delphi"&gt;&lt;br /&gt;procedure TBrightnessForm.GreenScrollBarChange(Sender: TObject);&lt;br /&gt;var&lt;br /&gt;  i,j:Integer;&lt;br /&gt;  temp:integer;&lt;br /&gt;  pixelPointer:PByteArray;&lt;br /&gt;  originalPixelPointer:PByteArray;&lt;br /&gt;begin&lt;br /&gt;  try&lt;br /&gt;    begin&lt;br /&gt;      for i:=0 to TemporaryImage.Picture.Height-1 do&lt;br /&gt;      begin&lt;br /&gt;        pixelPointer:=TemporaryImage.Picture.Bitmap.ScanLine[i];&lt;br /&gt;        originalPixelPointer:=OriginalImage.Picture.Bitmap.ScanLine[i];&lt;br /&gt;        for j:=0 to TemporaryImage.Picture.Width-1 do&lt;br /&gt;        begin&lt;br /&gt;          temp:=originalPixelPointer[3*j+1]+ GreenScrollBar.Position;&lt;br /&gt;          if temp&lt;0 then temp:=0;&lt;br /&gt;          if temp&gt;255 then temp:=255;&lt;br /&gt;          pixelPointer[3*j+1]:=temp;&lt;br /&gt;        end;&lt;br /&gt;      end;&lt;br /&gt;      TemporaryImage.Refresh;&lt;br /&gt;    end;&lt;br /&gt;  except&lt;br /&gt;    begin&lt;br /&gt;      Free;&lt;br /&gt;      ShowMessage('Cannot complete the operation');&lt;br /&gt;    end;&lt;br /&gt;  end;&lt;br /&gt;end;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Double click the BlueScrollBar component, the you'll be directed to its event handler, edit as shown below&lt;br /&gt;&lt;pre name="code" class="Delphi"&gt;&lt;br /&gt;procedure TBrightnessForm.BlueScrollBarChange(Sender: TObject);&lt;br /&gt;var&lt;br /&gt;  i,j:Integer;&lt;br /&gt;  temp:integer;&lt;br /&gt;  pixelPointer:PByteArray;&lt;br /&gt;  originalPixelPointer:PByteArray;&lt;br /&gt;begin&lt;br /&gt;  try&lt;br /&gt;    begin&lt;br /&gt;      for i:=0 to TemporaryImage.Picture.Height-1 do&lt;br /&gt;      begin&lt;br /&gt;        pixelPointer:=TemporaryImage.Picture.Bitmap.ScanLine[i];&lt;br /&gt;        originalPixelPointer:=OriginalImage.Picture.Bitmap.ScanLine[i];&lt;br /&gt;        for j:=0 to TemporaryImage.Picture.Width-1 do&lt;br /&gt;        begin&lt;br /&gt;          temp:=originalPixelPointer[3*j]+ BlueScrollBar.Position;&lt;br /&gt;          if temp&lt;0 then temp:=0;&lt;br /&gt;          if temp&gt;255 then temp:=255;&lt;br /&gt;          pixelPointer[3*j]:=temp;&lt;br /&gt;        end;&lt;br /&gt;      end;&lt;br /&gt;      TemporaryImage.Refresh;&lt;br /&gt;    end;&lt;br /&gt;  except&lt;br /&gt;    begin&lt;br /&gt;      Free;&lt;br /&gt;      ShowMessage('Cannot complete the operation');&lt;br /&gt;    end;&lt;br /&gt;  end;&lt;br /&gt;end;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Double click OKButton component, you'll be directed to its event handler, and edit it as shown below:&lt;br /&gt;&lt;pre name="code" class="Delphi"&gt;&lt;br /&gt;procedure TBrightnessForm.OKButtonClick(Sender: TObject);&lt;br /&gt;begin&lt;br /&gt;Applied:=true;&lt;br /&gt;Close();&lt;br /&gt;end;&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;li&gt;Double click CancelButton component, you'll be directed to its event handler, and edit it as shown below:&lt;br /&gt;&lt;pre name="code" class="Delphi"&gt;&lt;br /&gt;procedure TBrightnessForm.OKButtonClick(Sender: TObject);&lt;br /&gt;begin&lt;br /&gt;Applied:=false;&lt;br /&gt;Close();&lt;br /&gt;end; &lt;/pre&gt; &lt;span style="font-size:85%;"&gt;&lt;span style="font-weight: bold;font-family:courier new;" &gt;&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;&lt;li&gt;Edit BrightnessForm's OnClose even handler as shown below:&lt;br /&gt;&lt;pre name="code" class="Delphi"&gt;&lt;br /&gt;procedure TBrightnessForm.FormClose(Sender: TObject;&lt;br /&gt;var Action: TCloseAction);&lt;br /&gt;begin&lt;br /&gt;if Applied=false then&lt;br /&gt;TemporaryImage.Picture.Bitmap.Assign(&lt;br /&gt;OriginalImage.Picture.Bitmap);&lt;br /&gt;Action:=caFree;&lt;br /&gt;end;&lt;/pre&gt;&lt;/li&gt;&lt;/ol&gt;  &lt;span style="font-weight: bold;"&gt;Showing The Brightness Manipulation Form from Main Form&lt;/span&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Now you can call the brightness form from main form. To do this, we need to add a menu to provide the access, double click the main menu component in the main form, and add Brightness menu item under menu Image (Image-&gt;Brightness), see Figure 2.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_sU93Gokt0UY/SJAbEnqaMpI/AAAAAAAAACs/XzpfBDGiYXQ/s1600-h/brightness_menu.GIF"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://3.bp.blogspot.com/_sU93Gokt0UY/SJAbEnqaMpI/AAAAAAAAACs/XzpfBDGiYXQ/s320/brightness_menu.GIF" alt="" id="BLOGGER_PHOTO_ID_5228708933557432978" border="0" /&gt;&lt;/a&gt;&lt;span style="font-weight: bold;"&gt;Figure 2. Brightness Menu&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Write the event handler for the menu as shown below:&lt;br /&gt;&lt;pre name="code" class="Delphi"&gt;&lt;br /&gt;procedure TMainForm.Brightness1Click(Sender: TObject);&lt;br /&gt;begin&lt;br /&gt;if ImageForm&lt;&gt;nil then&lt;br /&gt;begin&lt;br /&gt;ImageForm:=TImageForm(ActiveMDIChild);&lt;br /&gt;try&lt;br /&gt;begin&lt;br /&gt;Application.CreateForm(TBrightnessForm,BrightnessForm);&lt;br /&gt;Brightnessform.SetBrightness(ImageForm.Image1);&lt;br /&gt;end;&lt;br /&gt;except&lt;br /&gt;BrightnessForm.Free;&lt;br /&gt;ShowMessage('Cannot complete the operation');&lt;br /&gt;end;&lt;br /&gt;end;&lt;br /&gt;end;&lt;/pre&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-weight: bold;font-family:courier new;" &gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_sU93Gokt0UY/SJAewHwLhWI/AAAAAAAAAC0/YNdbUuDCINM/s1600-h/brightness_exe.GIF"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://2.bp.blogspot.com/_sU93Gokt0UY/SJAewHwLhWI/AAAAAAAAAC0/YNdbUuDCINM/s320/brightness_exe.GIF" alt="" id="BLOGGER_PHOTO_ID_5228712979440829794" border="0" /&gt;&lt;/a&gt;&lt;span style="font-weight: bold;"&gt;Figure 3. Brightness Modification Execution&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Don't forget to add BrightnessUnit under the uses in the MainUnit's implementation. Use menu File-&gt;Use Unit (Alt+F11). Now you can save, compile and run the executable. The execution look like figure 3. &lt;a href="http://www.mediafire.com/?1segmxqbetj"&gt;Here you can download the source code for Delphi 7 project&lt;/a&gt; , and  &lt;a href="http://www.mediafire.com/?91t4cgrcxgm"&gt;Turbo Delphi Explorer project source code here&lt;/a&gt;.&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5740833303868793836-2435418948520070377?l=imageprocessingindelphi.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://imageprocessingindelphi.blogspot.com/feeds/2435418948520070377/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5740833303868793836&amp;postID=2435418948520070377' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5740833303868793836/posts/default/2435418948520070377'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5740833303868793836/posts/default/2435418948520070377'/><link rel='alternate' type='text/html' href='http://imageprocessingindelphi.blogspot.com/2008/07/brightness-manipulation-in-delphi.html' title='Brightness Manipulation in Delphi'/><author><name>techtalk</name><uri>http://www.blogger.com/profile/06105126060926155997</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_sU93Gokt0UY/SI_aqPWe5yI/AAAAAAAAACk/fAAo7VY1DGk/s72-c/brightness_gui.GIF' height='72' width='72'/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5740833303868793836.post-8249515766270024</id><published>2008-07-29T18:35:00.000-07:00</published><updated>2008-07-29T19:18:30.994-07:00</updated><title type='text'>Brightness Modification</title><content type='html'>&lt;div style="text-align: justify;"&gt;We can't read a book or see something clearly in a room with low light source. In real life, we can improve brightness by exposing the object with strong light source. In image processing, it's equivalent to white color (analogous  to light source) addition. This is done by simply adding a constant to each color element. When the constant is positive then the image become brighter and when the constant is negative then the image will be darker.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_sU93Gokt0UY/SI_LdQd_RzI/AAAAAAAAACM/FiwENJ_7LFg/s1600-h/brightness_gst.GIF"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://2.bp.blogspot.com/_sU93Gokt0UY/SI_LdQd_RzI/AAAAAAAAACM/FiwENJ_7LFg/s320/brightness_gst.GIF" alt="" id="BLOGGER_PHOTO_ID_5228621395897829170" border="0" /&gt;&lt;/a&gt;&lt;span style="font-weight: bold;"&gt;Figure 1. Brightness Manipulation Function Plot&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;The GST function for brightness manipulation ca be plotted as shown in figure 1. Remember that the addition with the constant is limited to 0-255 (8bit monochrome or 24bit true color format). The effect on the image's histogram is shown in figure 2.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_sU93Gokt0UY/SI_OGzHL-PI/AAAAAAAAACU/LFW03xGpOgU/s1600-h/brightness_histogram.GIF"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://4.bp.blogspot.com/_sU93Gokt0UY/SI_OGzHL-PI/AAAAAAAAACU/LFW03xGpOgU/s320/brightness_histogram.GIF" alt="" id="BLOGGER_PHOTO_ID_5228624308595325170" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-weight: bold;"&gt;Figure 2. Brightness Manipulation Effect on Image Histogram&lt;/span&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;For true color image, the modification for each color elements can be different. We can add more blue and reduce the red element to make different color source addition (equivalent to color light source exposure in real life).&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5740833303868793836-8249515766270024?l=imageprocessingindelphi.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://imageprocessingindelphi.blogspot.com/feeds/8249515766270024/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5740833303868793836&amp;postID=8249515766270024' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5740833303868793836/posts/default/8249515766270024'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5740833303868793836/posts/default/8249515766270024'/><link rel='alternate' type='text/html' href='http://imageprocessingindelphi.blogspot.com/2008/07/brightness-modification.html' title='Brightness Modification'/><author><name>techtalk</name><uri>http://www.blogger.com/profile/06105126060926155997</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_sU93Gokt0UY/SI_LdQd_RzI/AAAAAAAAACM/FiwENJ_7LFg/s72-c/brightness_gst.GIF' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5740833303868793836.post-5548489164641053406</id><published>2008-07-29T16:07:00.000-07:00</published><updated>2008-07-29T17:46:15.039-07:00</updated><title type='text'>Pixel Operation: An Introduction</title><content type='html'>&lt;div style="text-align: justify;"&gt;Pixel operation is operation of an image where each pixel's intensity value is modified. The modification/transformation depends solely on it's previous value, regardless of its position and other pixels value.  Some image operation in this category are brightness modification, contrast enhancement, color inversion (negation), and thresholding operation.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;Pixel operation is done by transforming each pixel value to new value according to a transformation function, known as gray-scale transformation (GST) function. This function map the gray-level input (&lt;span style="font-style: italic;"&gt;Ki&lt;/span&gt;) to an new gray-level output (&lt;span style="font-style: italic;"&gt;Ko&lt;/span&gt;). In general, a GST function can be expressed as:&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-style: italic;"&gt;Ko&lt;/span&gt;=&lt;span style="font-style: italic;"&gt;f(Ki&lt;/span&gt;)&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_sU93Gokt0UY/SI-1t20qkYI/AAAAAAAAACE/AkgosRpCj68/s1600-h/gst.gif"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://3.bp.blogspot.com/_sU93Gokt0UY/SI-1t20qkYI/AAAAAAAAACE/AkgosRpCj68/s320/gst.gif" alt="" id="BLOGGER_PHOTO_ID_5228597491815584130" border="0" /&gt;&lt;/a&gt;&lt;span style="font-weight: bold;"&gt;Figure 1. typical Gray-Scale Transformation (GST) Function Plot&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;The mapping of typical GST function can presented as transformation curve, as shown in Figure 1. The function can be linear or non-linear. In a true color image, GST function is applied to each RGB elements. Each function for each color element can take the same form or different depends on the application.&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5740833303868793836-5548489164641053406?l=imageprocessingindelphi.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://imageprocessingindelphi.blogspot.com/feeds/5548489164641053406/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5740833303868793836&amp;postID=5548489164641053406' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5740833303868793836/posts/default/5548489164641053406'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5740833303868793836/posts/default/5548489164641053406'/><link rel='alternate' type='text/html' href='http://imageprocessingindelphi.blogspot.com/2008/07/pixel-operation-introduction.html' title='Pixel Operation: An Introduction'/><author><name>techtalk</name><uri>http://www.blogger.com/profile/06105126060926155997</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_sU93Gokt0UY/SI-1t20qkYI/AAAAAAAAACE/AkgosRpCj68/s72-c/gst.gif' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5740833303868793836.post-6510402049102703926</id><published>2008-07-25T07:51:00.000-07:00</published><updated>2008-07-31T08:31:58.206-07:00</updated><title type='text'>Computing and Displaying Image Histogram in Delphi</title><content type='html'>&lt;div style="text-align: justify;"&gt;To make our own &lt;a href="http://imageprocessingindelphi.blogspot.com/2008/07/what-is-image-histogram.html"&gt;histogram analysis&lt;/a&gt; using Delphi, first you need to make (or download the source code) of &lt;a href="http://imageprocessingindelphi.blogspot.com/2008/07/writing-simple-graphical-user-interface.html"&gt;the graphical user interface for image processing&lt;/a&gt; we described in the previous chapter. To compute the image histogram, you need to make a vector variable to store the count of each pixel level. After that, you may begin to check the pixel value, and increment the variable that store the pixels count for that level. Histogram for color pixel is computed in the same way, but independently done for each R, G, and B element.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Creating Histogram Form&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;ol style="text-align: justify;"&gt;&lt;li&gt;Open the &lt;a href="http://imageprocessingindelphi.blogspot.com/2008/07/writing-simple-graphical-user-interface.html"&gt;GUI project&lt;/a&gt; created in the previous chapter.&lt;/li&gt;&lt;li&gt;Create a new form, change the form name property to HistogramForm, change the Caption to 'Histogram', set the ClientHeight property to 170, set the ClientWidth property to 275, and set the form style property to fsMDIChild.Make OnClose event handler, click Events tab on the object inspector, double click the OnClose event handler edit box. You'll be directed to the event handler, and change the Action variable to caFree between &lt;span style="font-weight: bold;"&gt;begin &lt;/span&gt;and &lt;span style="font-weight: bold;"&gt;end&lt;/span&gt;.&lt;br /&gt;&lt;pre name="code" class="Delphi"&gt;&lt;br /&gt;procedure THistogramForm.FormClose(Sender: TObject;&lt;br /&gt;var Action: TCloseAction);&lt;br /&gt;begin&lt;br /&gt;Action:=caFree;&lt;br /&gt;end;&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;li&gt;Go to menu Project-&gt;Options, on the Forms page, click HistogramForm to select, and press &gt; to move the it from auto created forms list to available forms list.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Save the unit (File-&gt;Save)  as HistogramUnit.&lt;/li&gt;&lt;/ol&gt;&lt;span style="font-weight: bold;"&gt;Adding Vector Variables to Store The Histogram&lt;/span&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;To add variables to store the histogram,  add the variables to the original HistogramForm  abstraction in private section. Also add a procedure &lt;span style="font-family:courier new;"&gt;ShowHistogram()&lt;/span&gt; to compute histogram in the public section. Add ExtCtrls in under the &lt;span style="font-weight: bold;"&gt;uses &lt;/span&gt;of the &lt;span style="font-weight: bold;"&gt;interface &lt;/span&gt;section, as we're going to use TImage in the form class abstraction.&lt;br /&gt;&lt;/div&gt;&lt;pre name="code" class="Delphi"&gt;uses&lt;br /&gt;ExtCtrls, Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs;&lt;br /&gt;&lt;br /&gt;type&lt;br /&gt;THistogramForm = class(TForm)&lt;br /&gt;procedure FormClose(Sender: TObject; var Action: TCloseAction);&lt;br /&gt;private&lt;br /&gt;{ Private declarations }&lt;br /&gt;MaxCount:Integer;&lt;br /&gt;HistogramGray:Array[0..255]of Integer;&lt;br /&gt;HistogramRed:Array[0..255]of Integer;&lt;br /&gt;HistogramGreen:Array[0..255]of Integer;&lt;br /&gt;HistogramBlue:Array[0..255]of Integer;&lt;br /&gt;public&lt;br /&gt;{ Public declarations }&lt;br /&gt;procedure ShowHistogram(Image:TImage);&lt;br /&gt;end;&lt;br /&gt;&lt;/pre&gt;&lt;span style="font-weight: bold;"&gt;Writing The Histogram Computation Procedure&lt;/span&gt;&lt;br /&gt;In the implementation, write the ShowHistogram procedure as shown below:&lt;br /&gt;&lt;pre name="code" class="Delphi"&gt;&lt;br /&gt;procedure THistogramForm.ShowHistogram(Image:TImage);&lt;br /&gt;var&lt;br /&gt;i,j:integer;&lt;br /&gt;pixelPointer:PByteArray;&lt;br /&gt;begin&lt;br /&gt;try&lt;br /&gt;begin&lt;br /&gt; for i:=0 to 255 do&lt;br /&gt; begin&lt;br /&gt;   HistogramGray[i]:=0;&lt;br /&gt;   HistogramRed[i]:=0;&lt;br /&gt;   HistogramGreen[i]:=0;&lt;br /&gt;   HistogramBlue[i]:=0;&lt;br /&gt; end;&lt;br /&gt; if Image.Picture.Bitmap.PixelFormat=pf8bit then&lt;br /&gt; begin&lt;br /&gt;   for i:=0 to Image.Height-1 do&lt;br /&gt;   begin&lt;br /&gt;     pixelPointer:=Image.Picture.Bitmap.ScanLine[i];&lt;br /&gt;     for j:=0 to Image.Width-1 do&lt;br /&gt;     begin&lt;br /&gt;       Inc(HistogramGray[pixelPointer[j]]);&lt;br /&gt;     end;&lt;br /&gt;   end;&lt;br /&gt;   MaxCount:=0;&lt;br /&gt;   for i:=0 to 255 do&lt;br /&gt;     if HistogramGray[i]&gt;MaxCount then&lt;br /&gt;   MaxCount:=HistogramGray[i];&lt;br /&gt; end;&lt;br /&gt; if Image.Picture.Bitmap.PixelFormat=pf24bit then&lt;br /&gt; begin&lt;br /&gt;   for i:=0 to Image.Height-1 do&lt;br /&gt;   begin&lt;br /&gt;     pixelPointer:=Image.Picture.Bitmap.ScanLine[i];&lt;br /&gt;     for j:=0 to Image.Width-1 do&lt;br /&gt;     begin&lt;br /&gt;       Inc(HistogramBlue[pixelPointer[3*j]]);&lt;br /&gt;       Inc(HistogramGreen[pixelPointer[3*j+1]]);&lt;br /&gt;       Inc(HistogramRed[pixelPointer[3*j+2]]);&lt;br /&gt;     end;&lt;br /&gt;   end;&lt;br /&gt;   for i:=0 to 255  do&lt;br /&gt;   begin&lt;br /&gt;     if HistogramRed[i]&gt;MaxCount then&lt;br /&gt;       MaxCount:=HistogramRed[i];&lt;br /&gt;     if HistogramGreen[i]&gt;MaxCount then&lt;br /&gt;       MaxCount:=HistogramGreen[i];&lt;br /&gt;     if HistogramBlue[i]&gt;MaxCount then&lt;br /&gt;       MaxCount:=HistogramBlue[i];&lt;br /&gt;   end;&lt;br /&gt; end;&lt;br /&gt; Canvas.MoveTo(10, 160);&lt;br /&gt; Canvas.Pen.Color:=clBlack;&lt;br /&gt; for i:=0 to 255 do&lt;br /&gt;   Canvas.LineTo(10+i,&lt;br /&gt;     160-round(150*HistogramGray[i]/MaxCount));&lt;br /&gt; Canvas.Pen.Color:=clRed;&lt;br /&gt; Canvas.MoveTo(10, 160);&lt;br /&gt; for i:=0 to 255 do&lt;br /&gt;   Canvas.LineTo(10+i,&lt;br /&gt;     160-(round(150*HistogramRed[i]/MaxCount)));&lt;br /&gt; Canvas.Pen.Color:=clGreen;&lt;br /&gt; Canvas.MoveTo(10, 160);&lt;br /&gt; for i:=0 to 255 do&lt;br /&gt;   Canvas.LineTo(10+i,&lt;br /&gt;     160-(round(150*HistogramGreen[i]/MaxCount)));&lt;br /&gt; Canvas.Pen.Color:=clBlue;&lt;br /&gt; Canvas.MoveTo(10, 160);&lt;br /&gt; for i:=0 to 255 do&lt;br /&gt;   Canvas.LineTo(10+i,&lt;br /&gt;     160-(round(150*HistogramBlue[i]/MaxCount)));&lt;br /&gt;end;&lt;br /&gt;except&lt;br /&gt; Free; //free the histogram form if an exception happens&lt;br /&gt; ShowMessage('Operation is not completed');&lt;br /&gt;end;&lt;br /&gt;end;&lt;/pre&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-weight: bold;"&gt;Histogram Form Repainting&lt;/span&gt;&lt;br /&gt;When the form is activated from minimized condition, we need to redraw the canvas we have drawn on ShowHistogram procedure. Place a focus on the histogram form, go to object inspector, on the Events tab, double click OnPaint event and we will be directed to the event handler, edit as shown below:&lt;br /&gt;&lt;pre name="code" class="Delphi"&gt;&lt;br /&gt;procedure THistogramForm.FormPaint(Sender: TObject);&lt;br /&gt;var&lt;br /&gt;i:integer;&lt;br /&gt;begin&lt;br /&gt;Canvas.MoveTo(10, 160);;&lt;br /&gt;Canvas.Pen.Color:=clBlack;&lt;br /&gt;for i:=0 to 255 do&lt;br /&gt;Canvas.LineTo(10+i,&lt;br /&gt; 160-round(150*HistogramGray[i]/MaxCount));&lt;br /&gt;Canvas.Pen.Color:=clRed;&lt;br /&gt;Canvas.MoveTo(10, 160);&lt;br /&gt;for i:=0 to 255 do&lt;br /&gt; Canvas.LineTo(10+i,&lt;br /&gt;  160-(round(150*HistogramRed[i]/MaxCount)));&lt;br /&gt;Canvas.Pen.Color:=clGreen;&lt;br /&gt;Canvas.MoveTo(10, 160);&lt;br /&gt;for i:=0 to 255 do&lt;br /&gt; Canvas.LineTo(10+i,&lt;br /&gt;   160-(round(150*HistogramGreen[i]/MaxCount)));&lt;br /&gt;Canvas.Pen.Color:=clBlue;&lt;br /&gt;Canvas.MoveTo(10, 160);&lt;br /&gt;for i:=0 to 255 do&lt;br /&gt; Canvas.LineTo(10+i,&lt;br /&gt;   160-(round(150*HistogramBlue[i]/MaxCount)));&lt;br /&gt;end;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Calling Histogram Procedure from Main Form&lt;br /&gt;&lt;/span&gt;To call showHistogram procedure, we need the user interface in the main form. On the main form, double click the MainMenu component, and add menu item Image-&gt;Histogram (see figure 1), then double click the Histogram item, so we will be directed to its event handler, and edit as shown below:&lt;br /&gt;&lt;pre name="code" class="Delphi"&gt;&lt;br /&gt;procedure TMainForm.Histogram1Click(Sender: TObject);&lt;br /&gt;begin&lt;br /&gt;if ImageForm&lt;&gt;nil then&lt;br /&gt;begin&lt;br /&gt;  ImageForm:=TImageForm(ActiveMDIChild);&lt;br /&gt;  try&lt;br /&gt;  begin&lt;br /&gt;    Application.CreateForm(THistogramForm,HistogramForm);&lt;br /&gt;    HistogramForm.ShowHistogram(ImageForm.Image1);&lt;br /&gt;  end;&lt;br /&gt;  except&lt;br /&gt;    HistogramForm.Free;&lt;br /&gt;    ShowMessage('Cannot complete the operation');&lt;br /&gt;  end;&lt;br /&gt;end;&lt;br /&gt;end;&lt;/pre&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-family:courier new;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-weight: bold;font-family:courier new;" &gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_sU93Gokt0UY/SI6d798gXFI/AAAAAAAAAB8/ZHsErZ1ukbk/s1600-h/histogram_menu.GIF"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://4.bp.blogspot.com/_sU93Gokt0UY/SI6d798gXFI/AAAAAAAAAB8/ZHsErZ1ukbk/s320/histogram_menu.GIF" alt="" id="BLOGGER_PHOTO_ID_5228289870989909074" border="0" /&gt;&lt;/a&gt;&lt;span style="font-weight: bold;"&gt;Figure 1. Image Histogram Main Menu&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;Make sure that in that main unit uses HistogramUnit under the &lt;span style="font-weight: bold;"&gt;uses &lt;/span&gt;of &lt;span style="font-weight: bold;"&gt;implementation &lt;/span&gt;section. Now you can save all form, compile, and run the executable. The example of executable running is shown in figure 2.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_sU93Gokt0UY/SI6SzjOAJ3I/AAAAAAAAAB0/jmKQhgapBQc/s1600-h/histogram_executable.GIF"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://3.bp.blogspot.com/_sU93Gokt0UY/SI6SzjOAJ3I/AAAAAAAAAB0/jmKQhgapBQc/s320/histogram_executable.GIF" alt="" id="BLOGGER_PHOTO_ID_5228277631748679538" border="0" /&gt;&lt;/a&gt;&lt;span style="font-weight: bold;"&gt;Figure 2. Image Histogram Execution&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Source Code Download&lt;/span&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;You can download the source code for both Delphi 7 and Turbo Delphi Explorer. &lt;a href="http://www.mediafire.com/?9mtjobnmzjm"&gt;The Delphi 7 source code can be downloaded here&lt;/a&gt;, and the &lt;a href="http://www.mediafire.com/?ixfwtgtywzu"&gt;Turbo Delphi Explorer source code here&lt;/a&gt;.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5740833303868793836-6510402049102703926?l=imageprocessingindelphi.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://imageprocessingindelphi.blogspot.com/feeds/6510402049102703926/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5740833303868793836&amp;postID=6510402049102703926' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5740833303868793836/posts/default/6510402049102703926'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5740833303868793836/posts/default/6510402049102703926'/><link rel='alternate' type='text/html' href='http://imageprocessingindelphi.blogspot.com/2008/07/computing-and-displaying-image.html' title='Computing and Displaying Image Histogram in Delphi'/><author><name>techtalk</name><uri>http://www.blogger.com/profile/06105126060926155997</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_sU93Gokt0UY/SI6d798gXFI/AAAAAAAAAB8/ZHsErZ1ukbk/s72-c/histogram_menu.GIF' height='72' width='72'/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5740833303868793836.post-8022041640239438376</id><published>2008-07-25T07:09:00.000-07:00</published><updated>2008-07-28T20:57:33.479-07:00</updated><title type='text'>The Purpose of Image Histogram Analysis</title><content type='html'>&lt;a href="http://imageprocessingindelphi.blogspot.com/2008/07/what-is-image-histogram.html"&gt;Image histogram&lt;/a&gt; analysis is very useful in image processing, some of the purposes are:&lt;br /&gt;&lt;ol&gt;&lt;li style="text-align: justify;"&gt;&lt;span style="font-weight: bold;"&gt;Selecting appropriate digitizing parameter&lt;/span&gt;. Histogram can be used to visually judge if an image is in an appropriate range of gray level. Ideally, digital image should use all available gray scale range, from minimum to maximum. This is important to optimize the display and other imaging devices to use all their potential capability. The imaging devices will be optimum if the they display (or print) the image data that contain optimum usage of its format (for example 0-255 for 8bit monochrome image).&lt;/li&gt;&lt;li style="text-align: justify;"&gt;&lt;span style="font-weight: bold;"&gt;Selection of Thresholding Level&lt;/span&gt;. One of image processing technique is thresholding, where all pixels above certain brightness level is maximized to the maximum value and others are minimized to the minimum value. &lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_sU93Gokt0UY/SInnAxhn37I/AAAAAAAAABs/i3q8gH6hFfQ/s1600-h/hitogram_thresholding.GIF"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://2.bp.blogspot.com/_sU93Gokt0UY/SInnAxhn37I/AAAAAAAAABs/i3q8gH6hFfQ/s320/hitogram_thresholding.GIF" alt="" id="BLOGGER_PHOTO_ID_5226962843020550066" border="0" /&gt;&lt;/a&gt;This is very useful in object and background separation if there is significant difference between an object and its background on an image.&lt;br /&gt;&lt;/li&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5740833303868793836-8022041640239438376?l=imageprocessingindelphi.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://imageprocessingindelphi.blogspot.com/feeds/8022041640239438376/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5740833303868793836&amp;postID=8022041640239438376' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5740833303868793836/posts/default/8022041640239438376'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5740833303868793836/posts/default/8022041640239438376'/><link rel='alternate' type='text/html' href='http://imageprocessingindelphi.blogspot.com/2008/07/purpose-of-image-histogram-analysis.html' title='The Purpose of Image Histogram Analysis'/><author><name>techtalk</name><uri>http://www.blogger.com/profile/06105126060926155997</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_sU93Gokt0UY/SInnAxhn37I/AAAAAAAAABs/i3q8gH6hFfQ/s72-c/hitogram_thresholding.GIF' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5740833303868793836.post-7612215648573727011</id><published>2008-07-25T06:12:00.000-07:00</published><updated>2008-08-05T20:56:38.068-07:00</updated><title type='text'>What Is An Image Histogram?</title><content type='html'>&lt;div style="text-align: justify;"&gt;Image histogram (gray level histogram) is one of simple and easy statistical tool for image analysis. From the histogram, many useful information of an image can be represented from an image. Image histogram is easy and fast to compute.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Gray level histogram is a function that show how many pixels for every gray level exist in an image. The x-axis is the gray level, and the y-axis is the number of pixels that have certain level appear on an image.&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_sU93Gokt0UY/SJkgKB6nM-I/AAAAAAAAAEs/laLwEBHvrpM/s1600-h/300px-Unequalized_Hawkes_Bay_NZ.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://3.bp.blogspot.com/_sU93Gokt0UY/SJkgKB6nM-I/AAAAAAAAAEs/laLwEBHvrpM/s400/300px-Unequalized_Hawkes_Bay_NZ.jpg" alt="" id="BLOGGER_PHOTO_ID_5231247798852596706" border="0" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;div&gt; &lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_sU93Gokt0UY/SJkgT1YrcdI/AAAAAAAAAE0/Skvtach-ONw/s1600-h/300px-Unequalized_Histogram.svg.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://2.bp.blogspot.com/_sU93Gokt0UY/SJkgT1YrcdI/AAAAAAAAAE0/Skvtach-ONw/s400/300px-Unequalized_Histogram.svg.png" alt="" id="BLOGGER_PHOTO_ID_5231247967287734738" border="0" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;span style="font-weight: bold;"&gt;Figure 1. An Image And Its Histogram&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Figure 1. Show an image and its histogram, you can show in the histogram that the pixels values (the gray level values) is distributed  only on the middle part of the available level, at levels between 100-200. We can say that the image doesn't maximize the usage of the available bit-depth (0-255).&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_sU93Gokt0UY/SJkgf0pFyyI/AAAAAAAAAE8/DNVNUA4AOUo/s1600-h/300px-Equalized_Hawkes_Bay_NZ.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://4.bp.blogspot.com/_sU93Gokt0UY/SJkgf0pFyyI/AAAAAAAAAE8/DNVNUA4AOUo/s400/300px-Equalized_Hawkes_Bay_NZ.jpg" alt="" id="BLOGGER_PHOTO_ID_5231248173246565154" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_sU93Gokt0UY/SJkgrhosYMI/AAAAAAAAAFE/krZzuZQrkIA/s1600-h/300px-Equalized_Histogram.svg.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://2.bp.blogspot.com/_sU93Gokt0UY/SJkgrhosYMI/AAAAAAAAAFE/krZzuZQrkIA/s400/300px-Equalized_Histogram.svg.png" alt="" id="BLOGGER_PHOTO_ID_5231248374303056066" border="0" /&gt;&lt;/a&gt;&lt;span style="font-weight: bold;"&gt;Figure 2. The Image And Its Histogram After Equalization&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;Using image processing techniques, we can manipulate the image to equalize the histogram, so we will have a better picture. The image and it's histogram after equalization is shown in Figure 2.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5740833303868793836-7612215648573727011?l=imageprocessingindelphi.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://imageprocessingindelphi.blogspot.com/feeds/7612215648573727011/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5740833303868793836&amp;postID=7612215648573727011' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5740833303868793836/posts/default/7612215648573727011'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5740833303868793836/posts/default/7612215648573727011'/><link rel='alternate' type='text/html' href='http://imageprocessingindelphi.blogspot.com/2008/07/what-is-image-histogram.html' title='What Is An Image Histogram?'/><author><name>techtalk</name><uri>http://www.blogger.com/profile/06105126060926155997</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_sU93Gokt0UY/SJkgKB6nM-I/AAAAAAAAAEs/laLwEBHvrpM/s72-c/300px-Unequalized_Hawkes_Bay_NZ.jpg' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5740833303868793836.post-8814966131339727778</id><published>2008-07-22T23:43:00.000-07:00</published><updated>2008-07-31T08:51:12.295-07:00</updated><title type='text'>Writing Simple Graphical User Interface for Image Processing</title><content type='html'>&lt;span style="font-weight: bold;"&gt;Basic Form&lt;/span&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;To learn image processing in Delphi by directly coding the algorithm, first we need to make our GUI (graphical user interface) to load an image, view, process, and show the result.&lt;br /&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;ol&gt;&lt;li&gt;Create a new project (File-&gt;New-&gt;Application  in Delphi 7 or File-&gt;New-&gt;VCL Form Application  in Turbo Delphi Explorer).&lt;/li&gt;&lt;li&gt;Set the FormStyle property of the form to fsMDIForm.&lt;/li&gt;&lt;li&gt;Change the form name from Form1 to MainForm.&lt;/li&gt;&lt;li&gt;Add a main  menu component  (from Standard component pallet) on the form, double click it and set a menu item File, with Open, Save, Close, and Exit sub menus.&lt;/li&gt;&lt;li&gt;Add an OpenPictureDialog (from Dialogs  component pallet)  and SavePictureDialog (from dialog component pallet) components on the form.&lt;/li&gt;&lt;li&gt;Set the Option.ofOverwritePrompt property of SavePictureDialog to true.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Add a status bar (from Win32 component pallet) on the form to ease the window resizing.&lt;/li&gt;&lt;li&gt;Resize the window as shown in figure 1.&lt;/li&gt;&lt;li&gt;Save the form (File-&gt;Save As), type MainUnit in the file name edit box.&lt;/li&gt;&lt;li&gt;Create a new form to display the the picture as a child window on the main form using menu File-&gt;New-&gt;Form.&lt;/li&gt;&lt;li&gt;Set the FormStyle property of the form to fsMDIChild.&lt;/li&gt;&lt;li&gt;Change the form name to ImageForm.&lt;/li&gt;&lt;li&gt;Resize the form as shown in the figure 2.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Add an Image component (from Additional component pallet).&lt;/li&gt;&lt;li&gt;Set the Align property of the Image component to alClient.&lt;/li&gt;&lt;li&gt;Set the Stretch property of the Image component to "true".&lt;/li&gt;&lt;li&gt;Set the Proportional property of the Image component to "true".&lt;/li&gt;&lt;li&gt;Save the form using menu File-&gt;Save as, and name it as ImageUnit.&lt;/li&gt;&lt;li&gt;Save the project using menu File-&gt;Save project as , name it with ImageProcessor, so this will be our executable file name if we compile it.&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_sU93Gokt0UY/SIdNteP6kgI/AAAAAAAAABU/nMj5pe5G1H4/s1600-h/MainForm.JPG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://1.bp.blogspot.com/_sU93Gokt0UY/SIdNteP6kgI/AAAAAAAAABU/nMj5pe5G1H4/s320/MainForm.JPG" alt="" id="BLOGGER_PHOTO_ID_5226231336196018690" border="0" /&gt;&lt;/a&gt;&lt;span style="font-weight: bold;"&gt;Figure 1. MainForm&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_sU93Gokt0UY/SIdNtrVL7qI/AAAAAAAAABc/qBxs9bTbH1A/s1600-h/ImageForm.JPG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://3.bp.blogspot.com/_sU93Gokt0UY/SIdNtrVL7qI/AAAAAAAAABc/qBxs9bTbH1A/s320/ImageForm.JPG" alt="" id="BLOGGER_PHOTO_ID_5226231339707788962" border="0" /&gt;&lt;/a&gt;&lt;span style="font-weight: bold;"&gt;Figure 2. ImageForm&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;After this steps, if we compile and run the executable, the child form will be shown because Delphi will auto-create it. This child form should be displayed only after executing a file operation, so we need to exclude the child form in auto-create: go to Project-&gt;Options-&gt;Form, point to ImageForm to select, and press the &gt; button, so the ImageForm will move to Available forms box, then press OK.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Writing From Closing Event Handler for Image Form&lt;br /&gt;&lt;/span&gt;When the image form is closed, we have to free the resources used by the form, view the ImageForm (Shift+F12 and select the ImageForm and press OK), then click Events tab on the object inspector, double click the OnClose edit box, you'll be directed to the event handler, and change the Action variable to caFree between &lt;span style="font-weight: bold;"&gt;begin &lt;/span&gt;and &lt;span style="font-weight: bold;"&gt;end&lt;/span&gt;.&lt;br /&gt;&lt;pre name="code" class="Delphi"&gt;&lt;br /&gt;procedure TImageForm.FormClose(Sender: TObject; var Action: TCloseAction);&lt;br /&gt;begin&lt;br /&gt; Action:=caFree;&lt;br /&gt;end;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Loading Image File&lt;br /&gt;&lt;/span&gt;Here some steps to load an image from a file:&lt;br /&gt;&lt;br /&gt;1. To load and display an image file, we will use ImageForm defined in ImageUnit, so click on MainForm and click menu File-&gt;Use Unit, and select ImageUnit then press OK. Make sure that &lt;span style="font-weight: bold;"&gt;uses &lt;/span&gt;ImageUnit is automatically added below the keyword &lt;span style="font-weight: bold;"&gt;implementation.&lt;/span&gt;&lt;br /&gt;&lt;pre name="code" class="Delphi"&gt;&lt;br /&gt;implementation&lt;br /&gt;&lt;br /&gt;uses ImageUnit;&lt;br /&gt;&lt;br /&gt;{$R *.dfm}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;2. Add ActiveX in the uses , this trick is needed to resolve TOpenPictureDiaolog bug (&lt;span&gt;showing access violation error, &lt;/span&gt;I find this bug on Delphi 7 running on Windows XP SP2). Now the &lt;span style="font-weight: bold;"&gt;uses &lt;/span&gt;section will look like this:&lt;br /&gt;&lt;pre name="code" class="Delphi"&gt;&lt;br /&gt;implementation&lt;br /&gt;&lt;br /&gt;uses ActiveX, ImageUnit;&lt;br /&gt;&lt;br /&gt;{$R *.dfm}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;As an integrated part of the trick, add an initialization and finalization just before the end of the file (before &lt;span style="font-weight: bold;"&gt;end.&lt;/span&gt;)&lt;span style="font-weight: bold;"&gt; &lt;/span&gt;like shown below:&lt;br /&gt;&lt;pre name="code" class="Delphi"&gt;&lt;br /&gt;initialization&lt;br /&gt;OleInitialize(nil);&lt;br /&gt;finalization&lt;br /&gt;OleUninitialize&lt;br /&gt;end.&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;3. Make an event handler of MainMenu1-&gt;File-&gt;Open, by double clicking the MainMenu1 component, and double click the Open menu. you will be directed to the script editor.&lt;br /&gt;&lt;pre name="code" class="Delphi"&gt;&lt;br /&gt;procedure TMainForm.Open1Click(Sender: TObject);&lt;br /&gt;begin&lt;br /&gt;&lt;br /&gt;end;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Edit that script as shown below:&lt;br /&gt;&lt;pre name="code" class="Delphi"&gt;&lt;br /&gt;procedure TMainForm.Open1Click(Sender: TObject);&lt;br /&gt;var&lt;br /&gt;formatInfo:string;&lt;br /&gt;begin&lt;br /&gt;if OpenPictureDialog1.Execute then&lt;br /&gt;begin&lt;br /&gt;Application.CreateForm(TImageForm, ImageForm);&lt;br /&gt;ImageForm.Image1.Picture.LoadFromFile(&lt;br /&gt;OpenPictureDialog1.FileName);&lt;br /&gt;ImageForm.ClientHeight:=&lt;br /&gt;  ImageForm.Image1.Picture.Height;&lt;br /&gt;ImageForm.ClientWidth:=&lt;br /&gt;  ImageForm.Image1.Picture.Width;&lt;br /&gt;case (ImageForm.Image1.Picture.Bitmap.PixelFormat) of&lt;br /&gt;  pf1bit : formatInfo:='Binary';&lt;br /&gt;  pf8bit : formatInfo:='Gray scale';&lt;br /&gt;  pf24bit: formatInfo:='True color';&lt;br /&gt;end;&lt;br /&gt;StatusBar1.SimpleText:= OpenPictureDialog1.FileName +' '+&lt;br /&gt;  IntToStr(ImageForm.Image1.Picture.Width) + 'x'+&lt;br /&gt;    IntToStr(ImageForm.Image1.Picture.Height) + ' '+&lt;br /&gt;      formatInfo;&lt;br /&gt;end;&lt;br /&gt;end;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Saving The Image to A File&lt;/span&gt;&lt;br /&gt;Although we haven't implemented the image processing code, we can implement file saving function right now. To write File-&gt;Save event handler, follow this steps:&lt;br /&gt;&lt;br /&gt;1. Double click the MainMenu1 component, and double click the Save item, you'll be directed to the event handler sript:&lt;br /&gt;&lt;pre name="code" class="Delphi"&gt;&lt;br /&gt;procedure TMainForm.Save1Click(Sender: TObject);&lt;br /&gt;begin&lt;br /&gt;&lt;br /&gt;end;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;2. Edit that script as shown below:&lt;br /&gt;&lt;pre name="code" class="Delphi"&gt;&lt;br /&gt;procedure TMainForm.Save1Click(Sender: TObject);&lt;br /&gt;begin&lt;br /&gt;try&lt;br /&gt;begin&lt;br /&gt; if SavePictureDialog1.Execute then&lt;br /&gt;     TImageForm(ActiveMDIChild).Image1.Picture.SaveToFile(&lt;br /&gt; SavePictureDialog1.FileName);&lt;br /&gt;end&lt;br /&gt;except&lt;br /&gt;     ShowMessage('Operation is not complete');&lt;br /&gt;end;&lt;br /&gt;end;&lt;/pre&gt;&lt;span style="font-weight: bold;font-family:courier new;font-size:85%;"  &gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_sU93Gokt0UY/SIiHdiCFLsI/AAAAAAAAABk/8Fy6UwOo0fM/s1600-h/ImageProcessor.JPG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://2.bp.blogspot.com/_sU93Gokt0UY/SIiHdiCFLsI/AAAAAAAAABk/8Fy6UwOo0fM/s320/ImageProcessor.JPG" alt="" id="BLOGGER_PHOTO_ID_5226576308984950466" border="0" /&gt;&lt;/a&gt;&lt;span style="font-weight: bold;"&gt;Figure 3. The Executable&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Writing File-&gt;Close Event Handler&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;1. Double click the MainMenu1 component, and double click the Close item, you'll be directed to the event handler sript:&lt;br /&gt;&lt;pre name="code" class="Delphi"&gt;&lt;br /&gt;procedure TMainForm.Close1Click(Sender: TObject);&lt;br /&gt;begin&lt;br /&gt;&lt;br /&gt;end;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;2. Edit that script as shown below:&lt;br /&gt;&lt;pre name="code" class="Delphi"&gt;&lt;br /&gt;procedure TMainForm.CLose1Click(Sender: TObject);&lt;br /&gt;begin&lt;br /&gt;   try&lt;br /&gt;     ActiveMDIChild.Close;&lt;br /&gt;   except&lt;br /&gt;     ShowMessage('Operation is not completed');&lt;br /&gt;   end;&lt;br /&gt;end;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;span style="font-size:85%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold;font-size:100%;" &gt;Writing File-&gt;Exit Event Handler&lt;br /&gt;&lt;/span&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-size:85%;"&gt;&lt;span style="font-size:100%;"&gt;To write File-Exit event handler, double click the MainMenu1 component, and double click the Close item, you'll be directed to the event handler sript, and add close; inside the begin-end:&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;pre name="code" class="Delphi"&gt;&lt;br /&gt;procedure TMainForm.Exit1Click(Sender: TObject);&lt;br /&gt;begin&lt;br /&gt; Close;&lt;br /&gt;end;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;/span&gt;Now you can compile and run the executable. Figure 3 show the executable viewing an image. You can download the source code of this GUI for Delphi 7 &lt;a href="http://www.mediafire.com/?x9enoefgmym" target="_blank"&gt;here&lt;/a&gt;, and for Turbo Delphi Explorer &lt;a href="http://www.mediafire.com/?tznjsjmnswt" target="_blank"&gt;here&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5740833303868793836-8814966131339727778?l=imageprocessingindelphi.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://imageprocessingindelphi.blogspot.com/feeds/8814966131339727778/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5740833303868793836&amp;postID=8814966131339727778' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5740833303868793836/posts/default/8814966131339727778'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5740833303868793836/posts/default/8814966131339727778'/><link rel='alternate' type='text/html' href='http://imageprocessingindelphi.blogspot.com/2008/07/writing-simple-graphical-user-interface.html' title='Writing Simple Graphical User Interface for Image Processing'/><author><name>techtalk</name><uri>http://www.blogger.com/profile/06105126060926155997</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_sU93Gokt0UY/SIdNteP6kgI/AAAAAAAAABU/nMj5pe5G1H4/s72-c/MainForm.JPG' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5740833303868793836.post-6913932810677070926</id><published>2008-07-22T23:21:00.000-07:00</published><updated>2008-07-22T23:43:06.365-07:00</updated><title type='text'>TImage, An Image Component in Delphi</title><content type='html'>&lt;div style="text-align: justify;"&gt;Delphi doesn't provide image processing component, so we have to write the processing algorithm by ourself, that's why this blog is written. Many third party image processing component are available, but we don't need it as we are going to learn on how to make it. To design the graphical user interface, Delphi (both Delphi pro and Turbo Delphi Explorer) provides TImage component.&lt;br /&gt;&lt;br /&gt;This component has Picture property that can be used to store image data. Picture property has a method called LoadFromFile that can be used to retrieve image data from a file. Other important TPicture sub-properties are:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;Height, represent the value of the image's height in pixel unit.&lt;/li&gt;&lt;li&gt;Width, represent the value of the image's width in pixel unit.&lt;/li&gt;&lt;li&gt;Bitmap, contain the data format information and the pixels values of the image.&lt;/li&gt;&lt;/ul&gt;The most common used format for for the bitmap are:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;pf1bit    The bitmap is a device-independent bitmap with one bit per pixel (black and white palette)&lt;/li&gt;&lt;li&gt;pf8bit    The bitmap is a device-independent bitmap that uses a 256color palette.&lt;/li&gt;&lt;li&gt;pf24bit    The bitmap is a device-independent true-color bitmap that uses 24 bits per pixel.&lt;/li&gt;&lt;/ul&gt;&lt;div style="text-align: justify;"&gt;When an image is first loaded from a file, the format will be the original format stored on that file, but we can change the bitmap format, and the data in the bitmap will be changed accordingly. Just be careful because this format conversion is not reversible.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5740833303868793836-6913932810677070926?l=imageprocessingindelphi.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://imageprocessingindelphi.blogspot.com/feeds/6913932810677070926/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5740833303868793836&amp;postID=6913932810677070926' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5740833303868793836/posts/default/6913932810677070926'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5740833303868793836/posts/default/6913932810677070926'/><link rel='alternate' type='text/html' href='http://imageprocessingindelphi.blogspot.com/2008/07/timage-image-component-in-delphi.html' title='TImage, An Image Component in Delphi'/><author><name>techtalk</name><uri>http://www.blogger.com/profile/06105126060926155997</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5740833303868793836.post-2433270779435950648</id><published>2008-07-22T20:53:00.000-07:00</published><updated>2008-08-05T20:42:07.516-07:00</updated><title type='text'>Digital Image Formats</title><content type='html'>&lt;div style="text-align: justify;"&gt;&lt;span style="font-size:100%;"&gt;There are many digital image representation such as raster and vector format. The raster type represent the image in pixels, while vector type represent the image in vector notation (curve, line, circle, etc). Only raster type will be discussed here. Raster image is constructed by many pixels, where each pixel is arranged in rows and columns. Each pixel can be addressed by its Cartesian coordinate. Within raster image, there are some very popular formats: binary, gray scale, true color, and indexed color.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-weight: bold;font-size:100%;" &gt;Binary Image&lt;span style="font-weight: bold;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;In binary image,  there are only two values: 0 or 1, representing two different colors. Most common color mapping is black for 0 and white for 1.  Example of binary image is shown in figure 1.&lt;br /&gt;&lt;/span&gt;&lt;div class="fullImageLink" id="file"&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-size:100%;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_sU93Gokt0UY/SJka-Akp_XI/AAAAAAAAAEE/4dC24FYekow/s1600-h/Neighborhood_watch_bw.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://1.bp.blogspot.com/_sU93Gokt0UY/SJka-Akp_XI/AAAAAAAAAEE/4dC24FYekow/s400/Neighborhood_watch_bw.png" alt="" id="BLOGGER_PHOTO_ID_5231242094775500146" border="0" /&gt;&lt;/a&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-weight: bold;"&gt;Figure 1. Binary Image&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-weight: bold;"&gt;Gray Scale&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span&gt;Using gray scale, the intensity of a pixel can vary in many values, giving smoother image. Each pixel can has many possible values, depending on the bit-depth of the format, for example, an 8 bit gray scale has 256 possible value for each pixel to represent the dot intensity. The most common color mapping for gray scale is black for 0 (zero) value, white for maximum value (255 in case of 8-bit image), and gray for values in between. Other color mapping is possible such as dark brown for zero and light orange for maximum value. An example of a gray scale image is shown in figure 2.&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;div style="text-align: justify;"&gt;&lt;div style="text-align: justify;"&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_sU93Gokt0UY/SJkb04ldppI/AAAAAAAAAEM/Zt6PfwgzF_U/s1600-h/Neighborhood_watch_grayscale.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://4.bp.blogspot.com/_sU93Gokt0UY/SJkb04ldppI/AAAAAAAAAEM/Zt6PfwgzF_U/s400/Neighborhood_watch_grayscale.jpg" alt="" id="BLOGGER_PHOTO_ID_5231243037524207250" border="0" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;span style="font-size:100%;"&gt;&lt;/span&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-weight: bold;"&gt;Figure 2. Gray Scale Image&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-weight: bold;"&gt;True Color Image&lt;/span&gt;&lt;br /&gt;In a color image, a specific color of a pixel is represented as a combination of three primary color: red, green, and blue (RGB),  therefor this true color format is also known as RGB format.  This RGB primary color is using display format, where the display device normally has red, green, and blue light source to construct a pixel. This is different with printing based representation that normally uses  cyan, magenta, and yellow (CMY) as their primary color, as used by printing devices.  For 24-bit  RGB format,  each element (red, green, and blue) uses 8 bit depth to represent its intensity, so there are 2^24  or more than 16 million of possible color value for  each pixel.  An example of true color image  is shown in figure 3.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div style="text-align: center;"&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_sU93Gokt0UY/SJkcSOEMOYI/AAAAAAAAAEU/-bUTS3_M77k/s1600-h/Neighborhood_watch_color.jpg"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://4.bp.blogspot.com/_sU93Gokt0UY/SJkcSOEMOYI/AAAAAAAAAEU/-bUTS3_M77k/s400/Neighborhood_watch_color.jpg" alt="" id="BLOGGER_PHOTO_ID_5231243541506439554" border="0" /&gt;&lt;/a&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-weight: bold;"&gt;Figure 3. A True Color Image&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-weight: bold;"&gt;Indexed Color Image&lt;br /&gt;&lt;/span&gt;The memory to store a true color image is three times than to store gray-scale image. Inpractical image, the number of colors is often limited, much less than 16 million combination, because the number of color in an image can't exceed the number of its pixels. Even if the number of pixels exceed 16 million, the number of colors can be much less. To reserve the computer's storage memory, an indexed color format is used for this case. In this format, each pixel is represent an index of a color table. &lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_sU93Gokt0UY/SJkc1l7M52I/AAAAAAAAAEc/KUsWiAQfmoE/s1600-h/Adaptative_8bits_palette_sample_image.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://2.bp.blogspot.com/_sU93Gokt0UY/SJkc1l7M52I/AAAAAAAAAEc/KUsWiAQfmoE/s400/Adaptative_8bits_palette_sample_image.png" alt="" id="BLOGGER_PHOTO_ID_5231244149206607714" border="0" /&gt;&lt;/a&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_sU93Gokt0UY/SJkc8Ibi9NI/AAAAAAAAAEk/dkyKNg8TFGw/s1600-h/Adaptative_8bits_palette.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://2.bp.blogspot.com/_sU93Gokt0UY/SJkc8Ibi9NI/AAAAAAAAAEk/dkyKNg8TFGw/s400/Adaptative_8bits_palette.png" alt="" id="BLOGGER_PHOTO_ID_5231244261548291282" border="0" /&gt;&lt;/a&gt;&lt;div style="text-align: center;"&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;span style="font-weight: bold;"&gt;Figure 4. Indexed Color Image and Its Colormap&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;div style="text-align: justify;"&gt;&lt;span style="font-weight: bold;"&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;This color table is known as color pallet or color map. Using this format, we can manipulate the color in all pixels faster, because we just need to manipulate the color map, which have much fewer element that the pixels. &lt;/span&gt;Figure 4 is a typical indexed 256-color image and its own palette (shown as a rectangle of swatches).&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5740833303868793836-2433270779435950648?l=imageprocessingindelphi.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://imageprocessingindelphi.blogspot.com/feeds/2433270779435950648/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5740833303868793836&amp;postID=2433270779435950648' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5740833303868793836/posts/default/2433270779435950648'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5740833303868793836/posts/default/2433270779435950648'/><link rel='alternate' type='text/html' href='http://imageprocessingindelphi.blogspot.com/2008/07/digital-image-format.html' title='Digital Image Formats'/><author><name>techtalk</name><uri>http://www.blogger.com/profile/06105126060926155997</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_sU93Gokt0UY/SJka-Akp_XI/AAAAAAAAAEE/4dC24FYekow/s72-c/Neighborhood_watch_bw.png' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5740833303868793836.post-598512130288602924</id><published>2008-07-03T07:10:00.000-07:00</published><updated>2008-07-09T16:41:14.681-07:00</updated><title type='text'>Image Processing Types</title><content type='html'>Many types of image processing can be classified into some categories:&lt;br /&gt;&lt;ol&gt;&lt;li style="text-align: justify;"&gt;Pixel operation, is an operation of pixels, that each pixel in an image is operated independently, means that the value of the pixel is not affected by other pixels value. It depends solely on its previous value and the operation parameters. Brightness and contrast manipulation are the examples.&lt;br /&gt;&lt;/li&gt;&lt;li style="text-align: justify;"&gt;Global operation, when a global characteristic of an image is used to deduct the parameter to operate each pixel.  The global characteristic is usually determined using statistical method, for example is automatic brightness and contrast equalization, where the histogram is redistributed for a better distribution.&lt;/li&gt;&lt;li style="text-align: justify;"&gt;Multi-frame operation, where an image is operated with other images to get a result. For example is the generation of transitional image of subsequent slow motion picture. When a 20 fps (frames per second) movie will be played back four times slower, it looks smoother if we show them in 20 fps with 3 additional transition frames between the two original frames, rather than show only the original frames by 5 fps.&lt;/li&gt;&lt;li style="text-align: justify;"&gt;Geometric operation, where the shape, size, or the orientation is modified. Resizing and skewing are some examples.&lt;/li&gt;&lt;li style="text-align: justify;"&gt;Neighboring pixels operation, where the result of a pixel operation depends not only on its previous value but also on other surrounding pixels values. Smoothing and sharpening operation are some examples.&lt;/li&gt;&lt;li style="text-align: justify;"&gt;Morphologic operation, is operation that is focused on specific image region. This operation is closely related to image analysis, because it deals with object/morph detection algorithm.&lt;/li&gt;&lt;/ol&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5740833303868793836-598512130288602924?l=imageprocessingindelphi.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://imageprocessingindelphi.blogspot.com/feeds/598512130288602924/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5740833303868793836&amp;postID=598512130288602924' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5740833303868793836/posts/default/598512130288602924'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5740833303868793836/posts/default/598512130288602924'/><link rel='alternate' type='text/html' href='http://imageprocessingindelphi.blogspot.com/2008/07/image-processing-types.html' title='Image Processing Types'/><author><name>techtalk</name><uri>http://www.blogger.com/profile/06105126060926155997</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-5740833303868793836.post-8232306118599955009</id><published>2008-06-12T02:57:00.000-07:00</published><updated>2008-07-25T15:28:05.777-07:00</updated><title type='text'>Introduction to Image Processing in Delphi</title><content type='html'>&lt;div style="text-align: justify;"&gt;Have you ever used Photoshop or other image processing software to make a cool impressive oil painting style of your photograph?  Do you know that  number of cars parking in basement can be deducted automatically by computer using the image captured by a camera in real time? That's what image processing done to make them possible.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Using Delphi is fun because you can design graphical user interface easily and rapidly. If you're familiar with Photoshop, Gimp, or other  image processing software, you might be wonder how such software is written. With image processing techniques, you can write a software to manipulate image brightness, contrast, finding the edge feature, giving emboss effect, or change the picture to an oil painting look. Learning image processing is really fun, and using Delphi as the development tools make it more fun. You will learn basic image processing concept, formulas, and advanced application of it.&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div style="text-align: justify;"&gt;Image processing deals with color manipulation, pixel-by-pixel operation, even frame-by-frame operation. In this blog, I will try to share and discuss many image processing techniques, rangin from basic to advanced topics.&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/5740833303868793836-8232306118599955009?l=imageprocessingindelphi.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://imageprocessingindelphi.blogspot.com/feeds/8232306118599955009/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=5740833303868793836&amp;postID=8232306118599955009' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5740833303868793836/posts/default/8232306118599955009'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5740833303868793836/posts/default/8232306118599955009'/><link rel='alternate' type='text/html' href='http://imageprocessingindelphi.blogspot.com/2008/06/introduction-to-image-processing-in.html' title='Introduction to Image Processing in Delphi'/><author><name>techtalk</name><uri>http://www.blogger.com/profile/06105126060926155997</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
