gpt4 book ai didi

image - 生成和使用许多图像失败

转载 作者:行者123 更新时间:2023-12-02 16:40:22 25 4
gpt4 key购买 nike

尝试处理大量图像时出现问题。如果这个数字很低,我可以运行算法,但是当我使用大量图像运行它时,它将不起作用。

因此,我有12张图像,并且需要从这些图像中再生成288张图像。我可以从第一张图像中生成第一组288张图像,并从第二张图像中生成第二组图像。但是之后,程序停止运行,然后出现以下错误:

“mm_areaopen:lib失败”

这是算法停止的代码:

for (int n = 0; n < 3; n++){

// tecido Normal -------------------------------------------------------------------------------------|

str_normal.str("");
title_normal.clear();
str_normal << "normal-" << n + 1 << ".tif";
title_normal = str_normal.str();
normal = title_normal.c_str();

original_normal = cvLoadImage(normal, CV_LOAD_IMAGE_GRAYSCALE);

image_names[i] = normal;

str_normal.str("");
title_normal.clear();
str_normal << "normal-" << n + 1 << "-selection" << ".tif";
title_normal = str_normal.str();
normal = title_normal.c_str();

goldStandard_normal = imread(normal, IMREAD_UNCHANGED);

// tecido NIC-1 -------------------------------------------------------------------------------------|

str_nic1.str("");
title_nic1.clear();
str_nic1 << "nic1-" << n + 1 << ".tif";
title_nic1 = str_nic1.str();
nic1 = title_nic1.c_str();

original_nic1 = cvLoadImage(nic1, CV_LOAD_IMAGE_GRAYSCALE);

image_names[i] = nic1;

str_nic1.str("");
title_nic1.clear();
str_nic1 << "nic1-" << n + 1 << "-selection" << ".tif";
title_nic1 = str_nic1.str();
nic1 = title_nic1.c_str();

goldStandard_nic1 = imread(nic1, IMREAD_UNCHANGED);

// tecido NIC-2 -------------------------------------------------------------------------------------|

str_nic2.str("");
title_nic2.clear();
str_nic2 << "nic2-" << n + 1 << ".tif";
title_nic2 = str_nic2.str();
nic2 = title_nic2.c_str();

original_nic2 = cvLoadImage(nic2, CV_LOAD_IMAGE_GRAYSCALE);

image_names[i] = nic2;

str_nic2.str("");
title_nic2.clear();
str_nic2 << "nic2-" << n + 1 << "-selection" << ".tif";
title_nic2 = str_nic2.str();
nic2 = title_nic2.c_str();

goldStandard_nic2 = imread(nic2, IMREAD_UNCHANGED);

// tecido NIC-3 -------------------------------------------------------------------------------------|

str_nic3.str("");
title_nic3.clear();
str_nic3 << "nic3-" << n + 1 << ".tif";
title_nic3 = str_nic3.str();
nic3 = title_nic3.c_str();

original_nic3 = cvLoadImage(nic3, CV_LOAD_IMAGE_GRAYSCALE);

image_names[i] = nic3;

str_nic3.str("");
title_nic3.clear();
str_nic3 << "nic3-" << n + 1 << "-selection" << ".tif";
title_nic3 = str_nic3.str();
nic3 = title_nic3.c_str();

goldStandard_nic3 = imread(nic3, IMREAD_UNCHANGED);

for (i = 0; i < 12; i++){

j = 0;

// tecido Normal -------------------------------------------------------------------------------------|

if (i >= 0 && i < 3){

for (p1 = 18; p1 <= 23; p1++){
for (p2 = 1; p2 <= 3; p2++){
for (p3 = 1; p3 <= 4; p3++){
for (p4 = 100; p4 <= 175; p4 = p4 + 25){

parameterSet[j].p1 = p1;
parameterSet[j].p2 = p2;
parameterSet[j].p3 = p3;
parameterSet[j].p4 = p4;

parameterSet[j].media = 0;

j++;

watershedImage_normal = Morphology::doPipeline(original_normal, p1, p2, p3, p4);
img_normal = watershedImage_normal;

cv::floodFill(img_normal, cvPoint(50, 50), cvScalar(255, 255, 255));
bitwise_not(img_normal, img_normal);

str_normal.str("");
title_normal.clear();
str_normal << "normal-" << n + 1 << "-" << p1 << "-" << p2 << "-" << p3 << "-" << p4 << ".tif";
title_normal = str_normal.str();

imwrite(title_normal, img_normal);

input_normal = imread(title_normal, IMREAD_UNCHANGED);

parameterSet[j].overlap[i] = caib::areaOverlap(goldStandard_normal, input_normal);

}
}
}
}
}

// tecido NIC-1 -------------------------------------------------------------------------------------|

if (i >= 3 && i < 6){

for (p1 = 18; p1 <= 23; p1++){
for (p2 = 1; p2 <= 3; p2++){
for (p3 = 1; p3 <= 4; p3++){
for (p4 = 100; p4 <= 175; p4 = p4 + 25){

watershedImage_nic1 = Morphology::doPipeline(original_nic1, p1, p2, p3, p4);
img_nic1 = watershedImage_nic1;

cv::floodFill(img_nic1, cvPoint(50, 50), cvScalar(255, 255, 255));
bitwise_not(img_nic1, img_nic1);

str_nic1.str("");
title_nic1.clear();
str_nic1 << "nic1-" << n + 1 << "-" << p1 << "-" << p2 << "-" << p3 << "-" << p4 << ".tif";
title_nic1 = str_nic1.str();

imwrite(title_nic1, img_nic1);

input_nic1 = imread(title_nic1, IMREAD_UNCHANGED);

parameterSet[j].overlap[i] = caib::areaOverlap(goldStandard_nic1, input_nic1);

}
}
}
}

}

// tecido NIC-2 -------------------------------------------------------------------------------------|

if (i >= 6 && i < 9){

for (p1 = 18; p1 <= 23; p1++){
for (p2 = 1; p2 <= 3; p2++){
for (p3 = 1; p3 <= 4; p3++){
for (p4 = 100; p4 <= 175; p4 = p4 + 25){

watershedImage_nic2 = Morphology::doPipeline(original_nic2, p1, p2, p3, p4);
img_nic2 = watershedImage_nic2;

cv::floodFill(img_nic2, cvPoint(50, 50), cvScalar(255, 255, 255));
bitwise_not(img_nic2, img_nic2);

str_nic2.str("");
title_nic2.clear();
str_nic2 << "nic2-" << n + 1 << "-" << p1 << "-" << p2 << "-" << p3 << "-" << p4 << ".tif";
title_nic2 = str_nic2.str();

imwrite(title_nic2, img_nic2);

input_nic2 = imread(title_nic2, IMREAD_UNCHANGED);

parameterSet[j].overlap[i] = caib::areaOverlap(goldStandard_nic2, input_nic2);

}
}
}
}
}

// tecido NIC-3 -------------------------------------------------------------------------------------|

if (i >= 9 && i < 12){

for (p1 = 18; p1 <= 23; p1++){
for (p2 = 1; p2 <= 3; p2++){
for (p3 = 1; p3 <= 4; p3++){
for (p4 = 100; p4 <= 175; p4 = p4 + 25){

watershedImage_nic3 = Morphology::doPipeline(original_nic3, p1, p2, p3, p4);
img_nic3 = watershedImage_nic3;

cv::floodFill(img_nic3, cvPoint(80, 80), cvScalar(255, 255, 255));
bitwise_not(img_nic3, img_nic3);

str_nic3.str("");
title_nic3.clear();
str_nic3 << "nic3-" << n + 1 << "-" << p1 << "-" << p2 << "-" << p3 << "-" << p4 << ".tif";
title_nic3 = str_nic3.str();

imwrite(title_nic3, img_nic3);

input_nic3 = imread(title_nic3, IMREAD_UNCHANGED);

parameterSet[j].overlap[i] = caib::areaOverlap(goldStandard_nic3, input_nic3);

}
}
}
}
}
}

打开所有的“nic1-1.tif”图像后,出现错误。有人知道为什么会这样吗?

顺便说一句,Morphology::doPipeline方法利用了C++ 1.6的SDC Morphology Toolbox。

对不起我的英语不好。

最佳答案

您可以像下面那样包装旧式库。请注意,您创建了一个IplImage,然后将其地址传递给需要IplImage *的函数。

 cv::Mat myPipeline(cv::Mat original_nic, int p1, int p2, int p3, int p4)
{
IplImage original_iplimage = IplImage(original_nic);
IplImage* watershedImage = Morphology::doPipeline( & original_iplimage , p1, p2, p3, p4);
cv::Mat result(watershedImage, true);
cvReleaseImage(watershedImage);
return result;
}

关于image - 生成和使用许多图像失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24946649/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com