资源简介
在一个经典的k-means算法程序上的改进,能够对图像进行分层输出,最大分层数位32.程序采用的是vs2005实现,内附有实验源码及实验结果图像,包括分2、4、8、32层的结果,希望对图像分割感兴趣的朋友有所帮助。

代码片段和文件信息
#include
#include
#include
#include
#include
#include “bmp.h“
using namespace std;
// **************************************************
// System Constant Definition
// **************************************************
// **************************************************
// Structures
// **************************************************
typedef struct MyBITMAPFILEHEADER_type {
char B;
char M;
unsigned int bfSize;
unsigned short int bfReserved1;
unsigned short int bfReserved2;
unsigned int bfOffBits;
char buf[14];
} MyBITMAPFILEHEADER;
typedef struct MyBITMAPINFOHEADER_type {
unsigned int biSize;
unsigned int biWidth;
unsigned int biHeight;
unsigned short int biPlanes;
unsigned short int biBitCount;
unsigned int biCompression;
unsigned int biSizeImage;
unsigned int biXPelsPerMeter;
unsigned int biYPelsPerMeter;
unsigned int biClrUsed;
unsigned int biClrImportant;
char buf[40];
} MyBITMAPINFOHEADER;
typedef struct MyRGBQUAD_type {
unsigned char palette[256][4];
char buf[256*4];
} MyRGBQUAD;
typedef unsigned char *ImageData;
typedef struct MyBITMAP_type {
MyBITMAPFILEHEADER file_header;
MyBITMAPINFOHEADER info_header;
MyRGBQUAD rgbquad;
ImageData image_data;
int bmp_gap;
} MyBITMAP;
// **************************************************
// Prototypes
// **************************************************
static void load_bmp_image(char filename[] MyBITMAP *bmp);
static void save_bmp_image(char filename[] MyBITMAP *bmp);
inline static void get_bmp_pixel(MyBITMAP *bmp int x int y int* color_r int* color_g int* color_b);
inline static void set_bmp_pixel(MyBITMAP *bmp int x int y int color_r int color_g int color_b);
// **************************************************
// Globals
// **************************************************
static MyBITMAP bmp_tmp;
static MyBITMAP bmp_cell;
static int bmp_gap = 0;
// **************************************************
// Image Tools
// **************************************************
// **************************************************
// open_bmp
// Open and load a bitmap image file into memory (3 RGB arrays of 1024x1024).
// **************************************************
void open_bmp(char filename[] unsigned int bmp_r[MaxBMPSizeX][MaxBMPSizeY] unsigned int bmp_g[MaxBMPSizeX][MaxBMPSizeY] unsigned int bmp_b[MaxBMPSizeX][MaxBMPSizeY] int& width int& height)
{
int r g b;
int x y;
load_bmp_image(filename &bmp_tmp);
width = bmp_tmp.info_header.biWidth;
height = bmp_tmp.info_header.biHeight;
cout<<“width:“<
cout<<“height:“<
if ((width > MaxBMPSizeX) || (height > MaxBMPSizeY)) {
cout << “该图片大小超过处理范围“ << endl;
exit(1);
}
for (x = 0; x <= width - 1; x++) {
for (y = 0; y <= height - 1; y++) {
get_bmp_pixel(&
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 348160 2009-12-22 11:49 kmeans_image\debug\kmeans_image.exe
文件 1217116 2009-12-22 11:49 kmeans_image\debug\kmeans_image.ilk
文件 1797120 2009-12-22 11:49 kmeans_image\debug\kmeans_image.pdb
文件 14928 2009-12-22 10:52 kmeans_image\kmeans_image\bmp.cpp
文件 1243 2009-12-21 10:53 kmeans_image\kmeans_image\bmp.h
文件 111526 2009-12-22 10:52 kmeans_image\kmeans_image\Debug\bmp.obj
文件 7316 2009-12-22 11:49 kmeans_image\kmeans_image\Debug\BuildLog.htm
文件 145 2009-12-22 11:49 kmeans_image\kmeans_image\Debug\kmeans_image.exe.intermediate.manifest
文件 184340 2009-12-22 11:49 kmeans_image\kmeans_image\Debug\k_means_image.obj
文件 67 2009-12-22 11:49 kmeans_image\kmeans_image\Debug\mt.dep
文件 216064 2009-12-22 11:49 kmeans_image\kmeans_image\Debug\vc80.idb
文件 3205 2009-12-19 16:53 kmeans_image\kmeans_image\kmeans_image.vcproj
文件 1411 2009-12-22 21:17 kmeans_image\kmeans_image\kmeans_image.vcproj.JEROSON.lijiazhi.user
文件 1427 2009-12-22 08:04 kmeans_image\kmeans_image\kmeans_image.vcproj.WWW-C9B62EF8BB0.Administrator.user
文件 7166 2009-12-27 15:53 kmeans_image\kmeans_image\k_means_image.cpp
文件 7042 2009-12-22 11:53 kmeans_image\kmeans_image\k_means_image.cpp.bak
文件 1379328 2009-12-22 21:17 kmeans_image\kmeans_image.ncb
文件 901 2009-12-19 16:48 kmeans_image\kmeans_image.sln
..A..H. 19456 2009-12-22 21:17 kmeans_image\kmeans_image.suo
文件 2359350 2009-12-22 11:35 kmeans_image\resource\2\2.bmp
文件 2359350 2009-12-22 11:38 kmeans_image\resource\2\xiamen_0.bmp
文件 2359350 2009-12-22 11:38 kmeans_image\resource\2\xiamen_1.bmp
文件 2359350 2009-12-22 11:38 kmeans_image\resource\2\xiamen_s_8.bmp
文件 2359350 2009-12-22 11:45 kmeans_image\resource\32\32.bmp
文件 2359350 2009-12-22 11:45 kmeans_image\resource\32\xiamen_0.bmp
文件 2359350 2009-12-22 11:45 kmeans_image\resource\32\xiamen_1.bmp
文件 2359350 2009-12-22 11:45 kmeans_image\resource\32\xiamen_10.bmp
文件 2359350 2009-12-22 11:45 kmeans_image\resource\32\xiamen_11.bmp
文件 2359350 2009-12-22 11:45 kmeans_image\resource\32\xiamen_12.bmp
文件 2359350 2009-12-22 11:45 kmeans_image\resource\32\xiamen_13.bmp
............此处省略63个文件信息
- 上一篇:Catia V5R20 参数化三种齿轮零件
- 下一篇:欧姆龙PLC通讯命令参考手册
相关资源
- FPGA实现PID.v
- 计算机图形学 边填充算法实现代码
-
Actionsc
ript 1.0实现能跟随鼠标运动的 - 基于蓝牙4.0的设备通信方案设计与实
- 基于PCIe的FPGA动态配置设计与实现
- SSM+Shiro+redis实现单点登陆
- 使用选择性重传协议实现UDP可靠通信
- 实现小波变换例子 upcoef 函数
- 图像二维小波变换的实现源代码
- 栈的实现及应用,六种基本算法
- 用汇编实现的学生成绩档案管理系统
- pb 实现仿BS界面 dw菜单 powerbuild
- 基于MIPS指令集的32位CPU设计与Verilog语
- python实现的ftp自动上传、下载脚本
- jQuery ajax实现简单登录验证
- 编程实现二维DCT变换
- 用Socket编程实现FTP
- gmsk调制在FPGA上实现
- 用51单片机实现G代码翻译
- NRF24L01实现51与STM32双向通讯
- 大数(链表、数组)实现
- 关联分析Apriori算法实现
- pb 实现ean8,ean13,ean39条形码数据窗口
- websocket实现一对一聊天
- Qt Creator opengl实现四元数鼠标控制轨迹
- 数据库实现学生成绩管理系统选课管
- 8位双向移位寄存器的设计与实现
- vhdl与lcd1602实现的多控制电子钟
- arcgis engine实现叠加分析
- MUSIC算法c 实现
评论
共有 条评论