The sample program is not what I want. I hope to be able to quickly load and process images, especially large-sized images. Using the sample program: display to load a large-sized dicom file (10k×5k) is three times slower than the software RadiAnt, so I want to use a parallel method to render the image. For updating complete images, you can use a parallel method to accelerate the process, which can achieve a speedup of about 3 times. However, for updating images in selected areas, I have adopted the following method:
void __fastcall TImageForm::UpdateImagePixels(WINSTRETCHPARAS &winStrechPara)
{
TIEBitmap *ProcBitmap;
TIEMask *mask;
int x1, y1, x2, y2;
if (!ImgEnMain->Proc->BeginImageProcessing(Hyiedefs::TIEPixelFormats()<<ie24RGB,
x1, y1, x2, y2, "FloatStrech", ProcBitmap, mask))
return;
int CPUCoreCount = ImageParas.CPUCoreCount;
std::vector<std::thread> threads;
const int chunkSize = (y2 - y1) / CPUCoreCount; //
TIERectangle sel;
sel = ImgEnMain->SelectedRect;
for (int i = 0; i < CPUCoreCount; ++i) {
int start = i * chunkSize;
int end = (i == CPUCoreCount - 1) ? (y2 - y1) : start + chunkSize;
threads.push_back(std::thread(ppkSetBlockPixels, std::ref(ImgEnMain), std::ref(RImage),
std::ref(mask), std::ref(sel), std::ref(winStrechPara), start, end, x1, x2));
}
ImgEnMain->Proc->EndImageProcessing(ProcBitmap, mask);
}
int __fastcall TImageForm::ppkSetBlockPixels(TImageEnView *imgen, TEImage *RImage, TIEMask *mask,
TIERectangle &sel, WINSTRETCHPARAS &winStrechPara,
int startln, int endln, int startr, int endr)
{
unsigned short xyGray;
Hyiedefs::PRGB px;
int x,y;
Hyiedefs::TRGB tmppx;
px = &tmppx;
for (int i = startln; i < endln; i++) {
y = sel.y + i;
for (int j = startr; j <= endr; j++) {
x = sel.x + j;
xyGray = RImage->ProcData[y][x] * FIMGScale;
if (winStrechPara.mbGrayStrech) {
xyGray = winStrechPara.GrayHisto[xyGray];
}
if (winStrechPara.mbWindowedShow) {
if (xyGray < winStrechPara.GWinLowvalue) {
xyGray = 0;
}
if (xyGray > winStrechPara.GWinUpvalue) {
xyGray = 255;
}
}
if (imgen->Selected){
if(mask->GetPixel(x, y) > 0) {
setPixelColor(px, xyGray);
imgen->IEBitmap->Pixels_ie24RGB[x][y] = *px;
}
}else{
setPixelColor(px, xyGray);
imgen->IEBitmap->Pixels_ie24RGB[x][y] = *px;
}
}
}
return 1;
}
But this method doesn't work. Why?