java.lang.IllegalArgumentException:未知图像类型0 - 使用PyramidIO

时间:2015-11-29 04:12:50

标签: java

我尝试使用PyramidIO https://github.com/NIST-ISG/pyramidio/releases为JavaScript OpenSeaDragon创建DZI文件。

我得到一个"未知图像类型0"错误让我感到困惑。它来自下面代码中的buildPyramid()。我在这里做的是用OpenCV读取tiff图像,将其转换为BufferedImage,然后编写该图像,以便PyramidIO可以拾取它并创建DZI。 buildPyramid()开始创建它应该创建的文件,但随后会出现此错误。有关于此的任何想法?谢谢。

@Controller
public class ImageController {
    @RequestMapping("/")
    public String image(Model model) throws IOException {
        File outputFolder = new File("C:\\Users\\Benjamin\\workspace\\J2\\util");
        File imageFile = new File("C:\\ML\\prostate_x100_trained\\x100\\B\\bprostate11-100x.tif");
        File outImageFile = new File("C:\\Users\\Benjamin\\workspace\\J2\\util\\outImage.png");
        Mat matImage = Imgcodecs.imread("C:\\ML\\prostate_x100_trained\\x100\\B\\bprostate11-100x.tif");
        BufferedImage bufImage = PathUtilities.ImageUtils.toBufferedImage(matImage); 
        ImageIO.write(bufImage, "png", outImageFile);

        ScalablePyramidBuilder spb = new ScalablePyramidBuilder(400, 2, "png", "dzi");
        FilesArchiver archiver = new DirectoryArchiver(outputFolder);
        PartialImageReader pir = new BufferedImageReader(imageFile);
        spb.buildPyramid(pir, "pyramidName", archiver, 1);

        model.addAttribute("message", "Test Message from controller.");
        return "image"; 
    }
}

这是我困惑的堆栈跟踪和输出。

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.3.0.RELEASE)

2015-11-28 22:43:28.476  INFO 10528 --- [           main] com.J2.J2Application                     : Starting J2Application on ThinkPad-W8 with PID 10528 (C:\Users\Benjamin\workspace\J2\bin started by Benjamin in C:\Users\Benjamin\workspace\J2)
2015-11-28 22:43:28.490  INFO 10528 --- [           main] com.J2.J2Application                     : No profiles are active
2015-11-28 22:43:29.675  INFO 10528 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@795509d9: startup date [Sat Nov 28 22:43:29 EST 2015]; root of context hierarchy
2015-11-28 22:43:32.388  INFO 10528 --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Overriding bean definition for bean 'beanNameViewResolver' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/ErrorMvcAutoConfiguration$WhitelabelErrorViewConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter; factoryMethodName=beanNameViewResolver; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter.class]]
2015-11-28 22:43:34.756  INFO 10528 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2015-11-28 22:43:34.802  INFO 10528 --- [           main] o.apache.catalina.core.StandardService   : Starting service Tomcat
2015-11-28 22:43:34.806  INFO 10528 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.0.28
2015-11-28 22:43:35.279  INFO 10528 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2015-11-28 22:43:35.291  INFO 10528 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 5628 ms
2015-11-28 22:43:36.726  INFO 10528 --- [ost-startStop-1] o.s.b.c.e.ServletRegistrationBean        : Mapping servlet: 'dispatcherServlet' to [/]
2015-11-28 22:43:36.746  INFO 10528 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'characterEncodingFilter' to: [/*]
2015-11-28 22:43:36.748  INFO 10528 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2015-11-28 22:43:36.749  INFO 10528 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2015-11-28 22:43:36.749  INFO 10528 --- [ost-startStop-1] o.s.b.c.embedded.FilterRegistrationBean  : Mapping filter: 'requestContextFilter' to: [/*]
2015-11-28 22:43:38.853  INFO 10528 --- [           main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@795509d9: startup date [Sat Nov 28 22:43:29 EST 2015]; root of context hierarchy
2015-11-28 22:43:39.142  INFO 10528 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/]}" onto public java.lang.String com.J2.controller.ImageController.image(org.springframework.ui.Model) throws java.io.IOException
2015-11-28 22:43:39.150  INFO 10528 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2015-11-28 22:43:39.152  INFO 10528 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest)
2015-11-28 22:43:39.331  INFO 10528 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2015-11-28 22:43:39.389  INFO 10528 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2015-11-28 22:43:39.648  INFO 10528 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2015-11-28 22:43:41.744  INFO 10528 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2015-11-28 22:43:42.175  INFO 10528 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
2015-11-28 22:43:42.202  INFO 10528 --- [           main] com.J2.J2Application                     : Started J2Application in 14.895 seconds (JVM running for 19.921)
2015-11-28 22:44:29.878  INFO 10528 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring FrameworkServlet 'dispatcherServlet'
2015-11-28 22:44:29.879  INFO 10528 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization started
2015-11-28 22:44:29.943  INFO 10528 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization completed in 64 ms
2015-11-28 22:48:57.943 ERROR 10528 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.IllegalArgumentException: Unknown image type 0] with root cause

java.lang.IllegalArgumentException: Unknown image type 0
    at java.awt.image.BufferedImage.<init>(Unknown Source) ~[na:1.8.0_60]
    at gov.nist.isg.pyramidio.tools.ImageResizingHelper.resizeImageGraphics2D(ImageResizingHelper.java:78) ~[pyramidio-cli-0.0.3.jar:0.0.3]
    at gov.nist.isg.pyramidio.tools.ImageResizingHelper.resizeImage(ImageResizingHelper.java:70) ~[pyramidio-cli-0.0.3.jar:0.0.3]
    at gov.nist.isg.pyramidio.ScalablePyramidBuilder$TileBuilder.buildTile(ScalablePyramidBuilder.java:194) ~[pyramidio-cli-0.0.3.jar:0.0.3]
    at gov.nist.isg.pyramidio.ScalablePyramidBuilder$TileBuilder.buildTile(ScalablePyramidBuilder.java:156) ~[pyramidio-cli-0.0.3.jar:0.0.3]
    at gov.nist.isg.pyramidio.ScalablePyramidBuilder$TileBuilder.buildTile(ScalablePyramidBuilder.java:156) ~[pyramidio-cli-0.0.3.jar:0.0.3]
    at gov.nist.isg.pyramidio.ScalablePyramidBuilder$TileBuilder.buildTile(ScalablePyramidBuilder.java:156) ~[pyramidio-cli-0.0.3.jar:0.0.3]
    at gov.nist.isg.pyramidio.ScalablePyramidBuilder$TileBuilder.buildTile(ScalablePyramidBuilder.java:156) ~[pyramidio-cli-0.0.3.jar:0.0.3]
    at gov.nist.isg.pyramidio.ScalablePyramidBuilder$TileBuilder.buildTile(ScalablePyramidBuilder.java:156) ~[pyramidio-cli-0.0.3.jar:0.0.3]
    at gov.nist.isg.pyramidio.ScalablePyramidBuilder$TileBuilder.buildTile(ScalablePyramidBuilder.java:156) ~[pyramidio-cli-0.0.3.jar:0.0.3]
    at gov.nist.isg.pyramidio.ScalablePyramidBuilder$TileBuilder.buildTile(ScalablePyramidBuilder.java:156) ~[pyramidio-cli-0.0.3.jar:0.0.3]
    at gov.nist.isg.pyramidio.ScalablePyramidBuilder$TileBuilder.buildTile(ScalablePyramidBuilder.java:156) ~[pyramidio-cli-0.0.3.jar:0.0.3]
    at gov.nist.isg.pyramidio.ScalablePyramidBuilder$TileBuilder.buildTile(ScalablePyramidBuilder.java:156) ~[pyramidio-cli-0.0.3.jar:0.0.3]
    at gov.nist.isg.pyramidio.ScalablePyramidBuilder$TileBuilder.buildTile(ScalablePyramidBuilder.java:156) ~[pyramidio-cli-0.0.3.jar:0.0.3]
    at gov.nist.isg.pyramidio.ScalablePyramidBuilder$TileBuilder.buildTile(ScalablePyramidBuilder.java:156) ~[pyramidio-cli-0.0.3.jar:0.0.3]
    at gov.nist.isg.pyramidio.ScalablePyramidBuilder$TileBuilder.buildTile(ScalablePyramidBuilder.java:128) ~[pyramidio-cli-0.0.3.jar:0.0.3]
    at gov.nist.isg.pyramidio.ScalablePyramidBuilder.buildPyramid(ScalablePyramidBuilder.java:89) ~[pyramidio-cli-0.0.3.jar:0.0.3]
    at com.J2.controller.ImageController.image(ImageController.java:38) ~[bin/:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_60]
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_60]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_60]
    at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_60]
    at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:222) ~[spring-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:137) ~[spring-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110) ~[spring-webmvc-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:814) ~[spring-webmvc-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:737) ~[spring-webmvc-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) ~[spring-webmvc-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959) ~[spring-webmvc-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893) ~[spring-webmvc-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970) ~[spring-webmvc-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861) ~[spring-webmvc-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:622) ~[tomcat-embed-core-8.0.28.jar:8.0.28]
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) ~[spring-webmvc-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) ~[tomcat-embed-core-8.0.28.jar:8.0.28]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291) ~[tomcat-embed-core-8.0.28.jar:8.0.28]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) ~[tomcat-embed-core-8.0.28.jar:8.0.28]
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) ~[tomcat-embed-websocket-8.0.28.jar:8.0.28]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) ~[tomcat-embed-core-8.0.28.jar:8.0.28]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) ~[tomcat-embed-core-8.0.28.jar:8.0.28]
    at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) ~[spring-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) ~[tomcat-embed-core-8.0.28.jar:8.0.28]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) ~[tomcat-embed-core-8.0.28.jar:8.0.28]
    at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:87) ~[spring-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) ~[tomcat-embed-core-8.0.28.jar:8.0.28]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) ~[tomcat-embed-core-8.0.28.jar:8.0.28]
    at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77) ~[spring-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) ~[tomcat-embed-core-8.0.28.jar:8.0.28]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) ~[tomcat-embed-core-8.0.28.jar:8.0.28]
    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:121) ~[spring-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) ~[spring-web-4.2.3.RELEASE.jar:4.2.3.RELEASE]
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) ~[tomcat-embed-core-8.0.28.jar:8.0.28]
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) ~[tomcat-embed-core-8.0.28.jar:8.0.28]
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:217) ~[tomcat-embed-core-8.0.28.jar:8.0.28]
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:106) [tomcat-embed-core-8.0.28.jar:8.0.28]
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502) [tomcat-embed-core-8.0.28.jar:8.0.28]
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142) [tomcat-embed-core-8.0.28.jar:8.0.28]
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) [tomcat-embed-core-8.0.28.jar:8.0.28]
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) [tomcat-embed-core-8.0.28.jar:8.0.28]
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:518) [tomcat-embed-core-8.0.28.jar:8.0.28]
    at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1091) [tomcat-embed-core-8.0.28.jar:8.0.28]
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:673) [tomcat-embed-core-8.0.28.jar:8.0.28]
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1500) [tomcat-embed-core-8.0.28.jar:8.0.28]
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1456) [tomcat-embed-core-8.0.28.jar:8.0.28]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [na:1.8.0_60]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [na:1.8.0_60]
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-8.0.28.jar:8.0.28]
    at java.lang.Thread.run(Unknown Source) [na:1.8.0_60]

0 个答案:

没有答案