LibCspCore 1.0.3

dotnet add package LibCspCore --version 1.0.3
                    
NuGet\Install-Package LibCspCore -Version 1.0.3
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="LibCspCore" Version="1.0.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="LibCspCore" Version="1.0.3" />
                    
Directory.Packages.props
<PackageReference Include="LibCspCore" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add LibCspCore --version 1.0.3
                    
#r "nuget: LibCspCore, 1.0.3"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package LibCspCore@1.0.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=LibCspCore&version=1.0.3
                    
Install as a Cake Addin
#tool nuget:?package=LibCspCore&version=1.0.3
                    
Install as a Cake Tool

LibCspCore — CSP 数字病理图像读取库

NuGet License

🔥 核心特性

高性能读取 CSP(Chinese Society of Pathology)数字病理图像格式,遵循《CSP 数字病理图像数据存储格式规范》。专为数字病理切片(Whole Slide Image)场景设计,适用于病理诊断、远程病理、AI 分析等领域。

  • Data Entry 树解析‌:支持递归解析 SEQUENCE 嵌套结构,完整提取金字塔层、瓦片索引、附加图像等元数据
  • 金字塔式瓦片索引‌:支持多分辨率层快速定位与 JPEG 瓦片读取,优化阅片体验
  • 文件句柄池技术‌:支持高并发场景下的文件句柄复用与元数据缓存
  • 统一接口设计‌:与 LibTiffCore(SVS/BigTIFF)共享 IWSIInfo/IWSILayerInfo/IWSIReaderProxy 接口,方便多格式集成调用
  • 跨平台支持‌:基于 .NET Standard 2.0,兼容 .NET Framework 4.6.1+ / .NET Core 3.1+ / .NET 5+
  • 小端二进制解析‌:支持 16/32/64 位三种寻址方式,覆盖全部 CSP 文件规格

📦 安装指南

dotnet add package LibCspCore --version 1.0.2

🚀 快速开始

using LibCspCore;
using LibTiffCore;

// 使用连接池(推荐)
using var pool = new CspReaderPool(
    fileHandleTimeout: TimeSpan.FromMinutes(5),
    cleanupInterval: TimeSpan.FromMinutes(1),
    metadataCacheExpiration: TimeSpan.FromHours(1),
    maxHandles: 10);

// 通过统一接口读取
IWSIReaderProxy reader = await pool.GetReaderAsync(@"path\to\slide.csp");
IWSIInfo info = reader.Info;

Console.WriteLine($"尺寸: {info.Width} x {info.Height}");
Console.WriteLine($"层数: {info.Layers.Count}");

// 读取指定层的瓦片
for (short level = 0; level < info.Layers.Count; level++)
{
    var layer = info.Layers[level];
    for (int row = 0; row < layer.Rows; row++)
    {
        for (int col = 0; col < layer.Cols; col++)
        {
            byte[] tileData = reader.ReadTileImg(level, row, col);
            // tileData 为 JPEG 原始字节,可直接保存或解码显示
        }
    }
}

// 读取附加图像(标签图/预览图/缩略图)
foreach (var kvp in info.AssociatedImages)
{
    byte[] imageBytes = reader.GetAssociatedImageJpegBytes(kvp.Key);
    File.WriteAllBytes($"{kvp.Key}.jpg", imageBytes);
}

🏗️ 项目架构

┌─────────────────────────────────────┐
│         你的应用程序                  │
├─────────────────────────────────────┤
│  IWSIInfo / IWSILayerInfo / ...     │  ← 统一接口
├──────────────────┬──────────────────┤
│   LibTiffCore     │   LibCspCore    │
│  (SVS/BigTIFF)   │   (CSP格式)     │
└──────────────────┴──────────────────┘

📖 CSP 格式简介

CSP(Chinese Society of Pathology)是中华医学会病理学分会制定的数字病理图像统一格式标准,后缀为 .csp。主要特点:

  • 128 字节定长文件头:魔数 "MEDIC",支持 16/32/64 位寻址
  • Data Entry 结构[2B MID][2B EID][2B DT] + [VN][VL] + [Value],SEQUENCE 类型支持递归嵌套
  • 金字塔多分辨率:从底层(最高分辨率)到顶层(最低分辨率),每层分割为固定尺寸的 JPEG 瓦片
  • 附加图像:支持标签图(Label)、预览图(Preview)、缩略图(Thumbnail)
  • 丰富元数据:扫描仪信息、扫描配置(倍率/MPP/压缩算法)、切片信息、患者信息、标注信息

🔗 相关项目

  • LibTiffCore — SVS/BigTIFF 格式读取库,与本库共享统一接口

📧 联系方式

如有问题,请发邮件至:kkkwp@foxmail.com

⚠️ 许可证

请勿用于商业用途,仅供学习交流使用。详见 LICENSE

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.3 59 7/1/2026
1.0.2 68 6/29/2026
1.0.1 62 6/29/2026
1.0.0 69 6/25/2026