CVI2012报错:Function imaqMorphology: (errorCode == -1074396154 [0xbff60406]). The image is not large e

简介: CVI2012报错:Function imaqMorphology: (errorCode == -1074396154 [0xbff60406]). The image is not large e

问题


用 LabWindows CVI2012 做图像的形态学处理的时候,处理图像出现报错:


NON-FATAL RUN-TIME ERROR:   "morph_pro.c", line 88, col 9, thread id 0x00000C28:   
Function imaqMorphology: (errorCode == -1074396154 [0xbff60406]). The image is not large enough for the operation.


代码部分:


#include "nivision.h"
#include <cvirte.h>  
#include <userint.h>
#include "morph_pro.h"
#include "nivision.h"
static int morphMoth;
static Image *SourceImage;
static Image *DestImage;
static Image *TempImage; 
int main (int argc, char *argv[])
{
  if (InitCVIRTE (0, argv, 0) == 0)
  return -1;  /* out of memory */
  if ((morphMoth = LoadPanel (0, "morph_pro.uir", MORPH_MOTH)) < 0)
  return -1;
  DisplayPanel (morphMoth);
  SourceImage = imaqCreateImage(IMAQ_IMAGE_U8, 2);
  DestImage = imaqCreateImage(IMAQ_IMAGE_U8, 2);
  TempImage = imaqCreateImage(IMAQ_IMAGE_U8, 2);   
  RunUserInterface ();
  DiscardPanel (morphMoth);
  return 0;
}
int CVICALLBACK Load_image(int panel, int control, int event,
  void *callbackData, int eventData1, int eventData2)
{
  char fileName[512];
  int status;
  HistogramReport *report;  
  switch (event)
  {
  case EVENT_COMMIT:
    status = FileSelectPopup("", "*.bmp*", "", "select an image file", VAL_LOAD_BUTTON, 0, 0, 1, 0, fileName);
  if (status == 1)
  {
  imaqReadFile(SourceImage, fileName, NULL, NULL);
  imaqMoveWindow(0, imaqMakePoint(50, 260));
  imaqDisplayImage(SourceImage, 0, TRUE);
  report = imaqHistogram(SourceImage, 256, 0, 255,
    IMAQ_IMAGE_U8);
  DeleteGraphPlot(morphMoth, MORPH_MOTH_HISTOGRAM, -1, VAL_IMMEDIATE_DRAW);
  PlotY(morphMoth, MORPH_MOTH_HISTOGRAM,
    (*report).histogram, 256,
    VAL_UNSIGNED_INTEGER, VAL_THIN_LINE,
    VAL_EMPTY_SQUARE, VAL_SOLID, 1, VAL_RED);
  }
  break;
  }
  return 0;
}
int CVICALLBACK Threshold(int panel, int control, int event,
  void *callbackData, int eventData1, int eventData2)
{
  int thre_value;
  HistogramReport *report; 
  switch (event)
  {
  case EVENT_COMMIT:
  GetCtrlVal(morphMoth, MORPH_MOTH_NUMERICSLIDE, &thre_value);
  imaqThreshold(DestImage, SourceImage, thre_value, 255,
    TRUE, 255);
  imaqSetWindowTitle(1, "二值化分割");
  imaqMoveWindow(1, imaqMakePoint(150, 260));
  imaqDisplayImage(DestImage, 1, TRUE);
  report = imaqHistogram(DestImage, 256, 0, 255, IMAQ_IMAGE_U8);
  DeleteGraphPlot(morphMoth, MORPH_MOTH_HISTOGRAM,
    -1, VAL_IMMEDIATE_DRAW);
  PlotY(morphMoth, MORPH_MOTH_HISTOGRAM, (*report).histogram,
    256, VAL_UNSIGNED_INTEGER, VAL_THIN_LINE, VAL_EMPTY_SQUARE,
    VAL_SOLID, 1, VAL_RED);
  break;
  }
  return 0;
}
int CVICALLBACK Morph_processing(int panel, int control, int event,
  void *callbackData, int eventData1, int eventData2)
{
  int methodValue;
  switch (event)
  {
  case EVENT_COMMIT:
  GetCtrlVal(morphMoth, MORPH_MOTH_MORPH_MOTHED, &methodValue);
  imaqMorphology(DestImage, TempImage, methodValue, NULL);  
  imaqSetWindowPalette(2, IMAQ_PALETTE_BINARY, NULL, 2);
  imaqSetWindowTitle(2, "形态学处理");
  imaqMoveWindow(2, imaqMakePoint(50, 60));
  imaqDisplayImage(DestImage, 2, TRUE);    
  imaqDisplayImage(TempImage, 2, TRUE);  
  break;
  }
  return 0;
}
int CVICALLBACK Save_an_image(int panel, int control, int event,
  void *callbackData, int eventData1, int eventData2)
{
  char SavePath[260];
  ImageInfo Image_Info;
  int status;
  int width, height;
  switch (event)
  {
  case EVENT_COMMIT:
  status = FileSelectPopup("", "*.bmp,*.tif,*.apd", "*.bmp", 
    "Select a SavePath", VAL_SAVE_BUTTON, 0, 0, 1, 0, SavePath);
  if (status)
  {
    imaqWriteFile(DestImage, SavePath, NULL);
  }
  break;
  }
  return 0;
}
int CVICALLBACK Quit (int panel, int control, int event,
  void *callbackData, int eventData1, int eventData2)
{
  switch (event)
  {
  case EVENT_COMMIT:
    QuitUserInterface (0);
    break;
  }
  return 0;
}


原因


TempImage 和 DestImage 尺寸大小不一


解决


在形态学处理之前,利用 imaqSetImageSize () 函数将两张图像缩放到同一尺寸


imaqSetImageSize(TempImage,640,320);    
  imaqSetImageSize(DestImage,640,320);


完整代码:


#include "nivision.h"
#include <cvirte.h>  
#include <userint.h>
#include "morph_pro.h"
#include "nivision.h"
static int morphMoth;
static Image *SourceImage;
static Image *DestImage;
static Image *TempImage; 
int main (int argc, char *argv[])
{
  if (InitCVIRTE (0, argv, 0) == 0)
  return -1;  /* out of memory */
  if ((morphMoth = LoadPanel (0, "morph_pro.uir", MORPH_MOTH)) < 0)
  return -1;
  DisplayPanel (morphMoth);
  SourceImage = imaqCreateImage(IMAQ_IMAGE_U8, 2);
  DestImage = imaqCreateImage(IMAQ_IMAGE_U8, 2);
  TempImage = imaqCreateImage(IMAQ_IMAGE_U8, 2);   
  RunUserInterface ();
  DiscardPanel (morphMoth);
  return 0;
}
int CVICALLBACK Load_image(int panel, int control, int event,
  void *callbackData, int eventData1, int eventData2)
{
  char fileName[512];
  int status;
  HistogramReport *report;  
  switch (event)
  {
  case EVENT_COMMIT:
    status = FileSelectPopup("", "*.bmp*", "", "select an image file", VAL_LOAD_BUTTON, 0, 0, 1, 0, fileName);
  if (status == 1)
  {
  imaqReadFile(SourceImage, fileName, NULL, NULL);
  imaqMoveWindow(0, imaqMakePoint(50, 260));
  imaqDisplayImage(SourceImage, 0, TRUE);
  report = imaqHistogram(SourceImage, 256, 0, 255,
    IMAQ_IMAGE_U8);
  DeleteGraphPlot(morphMoth, MORPH_MOTH_HISTOGRAM, -1, VAL_IMMEDIATE_DRAW);
  PlotY(morphMoth, MORPH_MOTH_HISTOGRAM,
    (*report).histogram, 256,
    VAL_UNSIGNED_INTEGER, VAL_THIN_LINE,
    VAL_EMPTY_SQUARE, VAL_SOLID, 1, VAL_RED);
  }
  break;
  }
  return 0;
}
int CVICALLBACK Threshold(int panel, int control, int event,
  void *callbackData, int eventData1, int eventData2)
{
  int thre_value;
  HistogramReport *report; 
  switch (event)
  {
  case EVENT_COMMIT:
  imaqSetImageSize(TempImage,640,320);    
  imaqSetImageSize(DestImage,640,320);
  GetCtrlVal(morphMoth, MORPH_MOTH_NUMERICSLIDE, &thre_value);
  imaqThreshold(DestImage, SourceImage, thre_value, 255,
    TRUE, 255);
  imaqSetWindowTitle(1, "二值化分割");
  imaqMoveWindow(1, imaqMakePoint(150, 260));
  imaqDisplayImage(DestImage, 1, TRUE);
  report = imaqHistogram(DestImage, 256, 0, 255, IMAQ_IMAGE_U8);
  DeleteGraphPlot(morphMoth, MORPH_MOTH_HISTOGRAM,
    -1, VAL_IMMEDIATE_DRAW);
  PlotY(morphMoth, MORPH_MOTH_HISTOGRAM, (*report).histogram,
    256, VAL_UNSIGNED_INTEGER, VAL_THIN_LINE, VAL_EMPTY_SQUARE,
    VAL_SOLID, 1, VAL_RED);
  break;
  }
  return 0;
}
int CVICALLBACK Morph_processing(int panel, int control, int event,
  void *callbackData, int eventData1, int eventData2)
{
  int methodValue;
  switch (event)
  {
  case EVENT_COMMIT:
  GetCtrlVal(morphMoth, MORPH_MOTH_MORPH_MOTHED, &methodValue);
  imaqMorphology(DestImage, TempImage, methodValue, NULL);  
  imaqSetWindowPalette(2, IMAQ_PALETTE_BINARY, NULL, 2);
  imaqSetWindowTitle(2, "形态学处理");
  imaqMoveWindow(2, imaqMakePoint(50, 60));
  imaqDisplayImage(DestImage, 2, TRUE);    
  imaqDisplayImage(TempImage, 2, TRUE);  
  break;
  }
  return 0;
}
int CVICALLBACK Save_an_image(int panel, int control, int event,
  void *callbackData, int eventData1, int eventData2)
{
  char SavePath[260];
  ImageInfo Image_Info;
  int status;
  int width, height;
  switch (event)
  {
  case EVENT_COMMIT:
  status = FileSelectPopup("", "*.bmp,*.tif,*.apd", "*.bmp", 
    "Select a SavePath", VAL_SAVE_BUTTON, 0, 0, 1, 0, SavePath);
  if (status)
  {
    imaqWriteFile(DestImage, SavePath, NULL);
  }
  break;
  }
  return 0;
}
int CVICALLBACK Quit (int panel, int control, int event,
  void *callbackData, int eventData1, int eventData2)
{
  switch (event)
  {
  case EVENT_COMMIT:
    QuitUserInterface (0);
    break;
  }
  return 0;
}
相关文章
|
29天前
|
Linux Python
【Azure Function】Python Function部署到Azure后报错No module named '_cffi_backend'
ERROR: Error: No module named '_cffi_backend', Cannot find module. Please check the requirements.txt file for the missing module.
|
5月前
|
弹性计算 监控 Serverless
函数计算操作报错合集之调用不成功,报错:Function instance health check failed on port 9000 in 120.7 seconds.该怎么办
在使用函数计算服务(如阿里云函数计算)时,用户可能会遇到多种错误场景。以下是一些常见的操作报错及其可能的原因和解决方法,包括但不限于:1. 函数部署失败、2. 函数执行超时、3. 资源不足错误、4. 权限与访问错误、5. 依赖问题、6. 网络配置错误、7. 触发器配置错误、8. 日志与监控问题。
|
6月前
|
弹性计算 缓存 Serverless
Serverless 应用引擎操作报错合集之阿里函数计算中我打开sd时遇到错误,信息为"Function instance exited unexpectedly(code 1, message:operation not permitted) with start command ' '."如何解决
Serverless 应用引擎(SAE)是阿里云提供的Serverless PaaS平台,支持Spring Cloud、Dubbo、HSF等主流微服务框架,简化应用的部署、运维和弹性伸缩。在使用SAE过程中,可能会遇到各种操作报错。以下是一些常见的报错情况及其可能的原因和解决方法。
298 6
|
3月前
|
缓存
【Azure Function】Function App代码中使用Managed Identity认证获取Blob数据时遇见400报错
【Azure Function】Function App代码中使用Managed Identity认证获取Blob数据时遇见400报错
【Azure Function】Function App代码中使用Managed Identity认证获取Blob数据时遇见400报错
|
3月前
解决微软云Azure Function运行报错-Value cannot be null. (Parameter ‘provider‘)
解决微软云Azure Function运行报错-Value cannot be null. (Parameter ‘provider‘)
79 4
|
4月前
|
JSON Java Serverless
函数计算操作报错合集之报错Function time out after该怎么办
Serverless 应用引擎(SAE)是阿里云提供的Serverless PaaS平台,支持Spring Cloud、Dubbo、HSF等主流微服务框架,简化应用的部署、运维和弹性伸缩。在使用SAE过程中,可能会遇到各种操作报错。以下是一些常见的报错情况及其可能的原因和解决方法。
|
3月前
|
存储 网络安全 数据中心
【Azure 应用服务】Function App / App Service 连接 Blob 报错
【Azure 应用服务】Function App / App Service 连接 Blob 报错
|
3月前
|
Linux C++ Docker
【Azure Developer】在Github Action中使用Azure/functions-container-action@v1配置Function App并成功部署Function Image
【Azure Developer】在Github Action中使用Azure/functions-container-action@v1配置Function App并成功部署Function Image
|
4月前
|
存储 缓存 Serverless
函数计算操作报错合集之如何处理运行时报错:“Function time out after 600 seconds”
在使用函数计算服务(如阿里云函数计算)时,用户可能会遇到多种错误场景。以下是一些常见的操作报错及其可能的原因和解决方法,包括但不限于:1. 函数部署失败、2. 函数执行超时、3. 资源不足错误、4. 权限与访问错误、5. 依赖问题、6. 网络配置错误、7. 触发器配置错误、8. 日志与监控问题。
|
3月前
|
JavaScript 前端开发 C++
【Azure Function】调试 VS Code Javascript Function本地不能运行,报错 Value cannot be null. (Parameter 'provider')问题
【Azure Function】调试 VS Code Javascript Function本地不能运行,报错 Value cannot be null. (Parameter 'provider')问题

热门文章

最新文章