目录
一 openslide 下载
二. 下载后工程配置
配置的时候遇到一个问题,困扰了一上午
之前写DEMO 一直在一个项目中累加,配置了这个之后,发现提示找不到程序入口
百思不得其解,后来换了一个地方就好了。。。
猜测是之前的demo里面依赖了太多的库,可能存在某些库冲突了
三. 测试代码
#include "openslide.h"
int test_Openslide()
{
std::cout << "enter openslide" << std::endl;
string fileName = "D:/20165478-1-20191220090726-001.tiff";
openslide_t* slide = openslide_open(fileName.c_str());
int32_t level = openslide_get_level_count(slide);
std::cout << level << std::endl;
int64_t w, h;
openslide_get_level0_dimensions(slide, &w, &h);
std::cout << w << "," << h << std::endl;
for (int i = 0; i < level; i++)
{
openslide_get_level_dimensions(slide, i, &w, &h);
std::cout << "level " << i << " dimension:" << w << "," << h << std::endl;
}
for (int i = 0; i < level; i++)
{
std::cout << "level " << i << " donwnsmaple:" << openslide_get_level_downsample(slide, i) << std::endl;
}
std::cout << "best level for downsmaple:" << openslide_get_best_level_for_downsample(slide, (openslide_get_level_downsample(slide, 0))) << std::endl;
int nWidth = 1024;
int nHeight = 1024;
uint32_t *pucData = new uint32_t[nWidth * nHeight * 3];
openslide_read_region(slide, pucData, 1000, 1000, 0, nWidth, nHeight);
cv::Mat img(nHeight, nWidth, CV_8UC(3), (void *)pucData, nWidth*3);
cv::imshow("img", img);
cv::waitKey(0);
delete[]pucData;
return 1;
}
四. 测试结果