⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 readme.txt

📁 segmentation sample good luck
💻 TXT
字号:
========================================================================

Segment application - This application is an adjunct to the Dr. Dobbs
		Journal article describing segmentation of images into background
		and foreground. The application was created using Microsoft
		Visual C++ 5.0.

The segment demo program displays a bitmap and segments it, initially using
by thresholding using brightness at 50% brightness. The demo assumes that
white is background and black is foreground. The demo program processes
either 256 color bitmaps or monochrome (1 bit) bitmaps.

Start the program and use File/Open off of the menu to open an appropriate
bitmap file (I've provided two bitmaps here, an image taken through
a microscope of a microscopic bullseye on a slide and an image of a
page of text). The program initially thresholds the image and paints
the outlines of the segmented shapes in red.

NOTE: you'll need to adjust the threshold to use the bullseye bitmap. See
	the documentation for Image/Histogram.

If you have any questions or comments, I can be reached at:
Lee Kamentsky
email: LeeK@email.msn.com

========================================================================

Segment operations:
    You may select a blob in order to perform operations on it. Select
	a blob by clicking on it. The selected blob is green.

Segment commands:

	You can exercise the following commands from the menu:

File/Open - loads a 256 color or monochrome bitmap
File/Export - saves the current bitmap as a monochrome bitmap.
View/Toolbar - hides and shows the toolbar at the top of the page
View/Status Bar - hides and shows the status bar at the bottom of the page
View/Reverse Video - toggles between display of the image as in the file and
			as an image with the colors' brightnesses reversed.

Blob/Statistics - Display statistics for the selected blob. The blob's area
			(in pixels), centroid X and Y, # of loops and enclosing rectangle
			are displayed.
Blob/Choose Template - Make the current selected blob the current matching template.
			The current template is displayed in blue. It overlays the selected
			blob.
Blob/Match - Match the current matching template against the selected
			blob. NOTE: you can do the same thing by pressing the left mouse
			button down on any blob. The match score appears in a tool tip.
			Match scores range from 0 (no correlation) to 1 (all pixels match).
			
Image/Histogram - This command displays a histogram of the numbers of pixels
			at each brightness level. It also has a tool to use to set the threshold.
			You can drag the tool's selection rectangle around to set the threshold.
			Typically, when viewing a black image on a white background, you'll
			see two peaks in the histogram; one for the typical text brightness
			and one for the background brightness. Set the threshold midway
			between these two peaks.

Image/Find Bullseye - This command searches the bitmap for concentric rings
			containing a bullseye target in their middle. It displays the
			bullseye blobs in yellow.

========================================================================

The code:

The code is organized as a typical MFC doc/view structured project. I do
not serialize bitmaps because it requires that they be read once and written
once before being touched by any significant code (during which they get
read a second time). I use CreateFileMapping to map the bitmap into memory
straight from the file; the bitmap file becomes the backing store for the
memory representation. Anyway, here's a blow-by-blow of the files in the
project.

blob.{cpp,h} - Implements the CBlob data structure
BlobStatsDlg.{cpp,h} - This is the dialog behind the Blob/Statistics command.
Bullseye.bmp - This is a 256 gray image of a bullseye that's deposited on
	       a microscope slide using photo-lithography. The bullseye target
	       is, I believe, 5 microns in diameter. This is roughly 1/4 of
	       the diameter of a cell. Each pixel is approximately 1/2 micron
	       square (which is wicked small!).
DibDoc.{cpp,h} - Implements CDIBDoc which is derived from CImageDoc. CDIBDoc
		 is the doc class, pretty much, in the doc/view paradigm.
HistogramDlg.{cpp,h} - This implements the brightness histogram dialog. The
	dialog really doesn't do much except act as a frame for the histogram
	window.
HistogramWnd.{cpp,h> - Implements CHistogramWnd. This class displays the
	brightness histogram and provides the user interface for adjusting
	the threshold.
ImageDoc.{cpp,h} - CImageDoc is the base class for all image documents in
	this program. I envisioned adding JPEG support as a derived class
	but I have never got around to hacking it in.
Line.{cpp,h} - Implements CLine. Each line represents one run-length above
	threshold.
MainFrm.{cpp.h} - This is CMainFrame which implements the frame window that
	the view sits in. I believe that I may have never viewed this file;
	it is probably as pristine as the day the wizard created it.
MdBW.bmp - This is a page from the first chapter of Moby Dick. I took the
    text from the Gutenberg Project site, composed a two-column page of
	text (I believe the font is Times New Roman, 10pt), printed the page,
	then scanned it in using a 600x600 resolution. The file is a 1 bit
	per pixel bitmap with black (zero) text on a white background.
MonochromeBitmap.{cpp,h} Perhaps CMonochromeBitmap is a bad name. The idea was
	to have a class that represented a bitmap of rasters of binary
	pixels. Each type of image has an associated derived class which
	implements the functions necessary to present the segmenter with
	rasters of binary pixels.
	MonochromeBitmap contains two versions of the segmenter. One just
	segments monochrome rasters. The other thresholds and segments
	256 color rasters.
QuadTree.h - This implements the template <class T> class CQuadTree. Really,
	this is a worthwhile piece of code for image processing. Quad trees
	organize the X-Y plane binomially into successively smaller blocks.
	You can search a quad tree for a member (or search for all members
	in a rectangular region) in log N time. There's really only two
	ways to consider ordering objects in two dimensions for sorting. This
	is one way, the other is the Hilbert curve, which is awesome, but
	that's another story for another day.
ReadMe.txt - this file.
Segment.clw - MFC's class wizard representation of this project
Segment.{cpp,h} - CSegmentApp resides here.
Segment.dsp - Segment project file
Segment.dsw - Segment workspace.
Segment.rc - resource file for segment
SegmentView.{cpp,h} - Implements CSegmentView. This is derived from CScrollView
	which makes it very easy to implement a view on a bitmap or other
	image of known size. CSegmentView controls blob selection and
	most of the menu commands.
StdAfx.{cpp,h} - MFC generates these to hack its .PCH precompiled header files.
========================================================================
       MICROSOFT FOUNDATION CLASS LIBRARY : Segment
========================================================================


AppWizard has created this Segment application for you.  This application
not only demonstrates the basics of using the Microsoft Foundation classes
but is also a starting point for writing your application.

This file contains a summary of what you will find in each of the files that
make up your Segment application.

Segment.h
    This is the main header file for the application.  It includes other
    project specific headers (including Resource.h) and declares the
    CSegmentApp application class.

Segment.cpp
    This is the main application source file that contains the application
    class CSegmentApp.

Segment.rc
    This is a listing of all of the Microsoft Windows resources that the
    program uses.  It includes the icons, bitmaps, and cursors that are stored
    in the RES subdirectory.  This file can be directly edited in Microsoft
	Developer Studio.

res\Segment.ico
    This is an icon file, which is used as the application's icon.  This
    icon is included by the main resource file Segment.rc.

res\Segment.rc2
    This file contains resources that are not edited by Microsoft 
	Developer Studio.  You should place all resources not
	editable by the resource editor in this file.

Segment.clw
    This file contains information used by ClassWizard to edit existing
    classes or add new classes.  ClassWizard also uses this file to store
    information needed to create and edit message maps and dialog data
    maps and to create prototype member functions.

/////////////////////////////////////////////////////////////////////////////

For the main frame window:

MainFrm.h, MainFrm.cpp
    These files contain the frame class CMainFrame, which is derived from
    CFrameWnd and controls all SDI frame features.

res\Toolbar.bmp
    This bitmap file is used to create tiled images for the toolbar.
    The initial toolbar and status bar are constructed in the
    CMainFrame class.  Edit this toolbar bitmap along with the
    array in MainFrm.cpp to add more toolbar buttons.

/////////////////////////////////////////////////////////////////////////////

AppWizard creates one document type and one view:

ImageDoc.h, ImageDoc.cpp - the document
    These files contain your CImageDoc class.  Edit these files to
    add your special document data and to implement file saving and loading
    (via CImageDoc::Serialize).

SegmentView.h, SegmentView.cpp - the view of the document
    These files contain your CSegmentView class.
    CSegmentView objects are used to view CImageDoc objects.



/////////////////////////////////////////////////////////////////////////////
Other standard files:

StdAfx.h, StdAfx.cpp
    These files are used to build a precompiled header (PCH) file
    named Segment.pch and a precompiled types file named StdAfx.obj.

Resource.h
    This is the standard header file, which defines new resource IDs.
    Microsoft Developer Studio reads and updates this file.

/////////////////////////////////////////////////////////////////////////////
Other notes:

AppWizard uses "TODO:" to indicate parts of the source code you
should add to or customize.

If your application uses MFC in a shared DLL, and your application is 
in a language other than the operating system's current language, you
will need to copy the corresponding localized resources MFC40XXX.DLL
from the Microsoft Visual C++ CD-ROM onto the system or system32 directory,
and rename it to be MFCLOC.DLL.  ("XXX" stands for the language abbreviation.
For example, MFC40DEU.DLL contains resources translated to German.)  If you
don't do this, some of the UI elements of your application will remain in the
language of the operating system.

/////////////////////////////////////////////////////////////////////////////

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -