一句话:提出 im2im,用知识图谱自动生成并执行内存图像表示转换代码,消除视觉编程中的手工类型转换。
图像处理工作流常组合来自不同库的函数,但各库对图像的内存表示不同,用户须处理数据类型、颜色通道、通道顺序、minibatch 布局、内存位置和像素强度范围等转换细节,这在视觉编程语言(VPL)中尤为干扰。im2im 是一个 Python 库,以知识图谱描述图像表示及转换规则,查询图谱生成并执行转换代码,自动将图像转为目标表示。在两个块式 VPL 案例中,与基础工作流对比表明 im2im 能自动完成类型转换、无需人工干预;与显式中间表示方案相比只生成必要转换,避免中间格式往返开销;与单函数方案相比,其开销不影响实用。该方法可推广至其他 VPL 和文本编程环境。
Image processing workflows typically consist of a series of different functions, each working with “image” inputs and outputs in an abstract sense. However, the specific in-memory representation of images differs between and sometimes within libraries. Conversion is therefore necessary when integrating functions from several sources into a single program. The conversion process forces users to consider low-level implementation details, including data types, color channels, channel order, minibatch layout, memory locations, and pixel intensity ranges. Specifically in the case of visual programming languages (VPLs), this distracts from high- level operations. We introduce im2im, a Python library that automates the conversion of in-memory image representations. The central concept of this library is a knowledge graph that describes image representations and how to convert between them. The system queries this knowledge graph to generate the conversion code and execute it, converting an image to the desired representation. The effectiveness of the approach is evaluated through two case studies in VPLs. In each case, we compared a workflow created in a basic blockbased VPL with the same workflow enhanced using im2im. These evaluations show that im2im automates type conversions and eliminates the need for manual intervention. Additionally, we compared the overhead of using explicit intermediate representations versus im2im, both of which avoid manual type conversions in VPLs. The results indicate that im2im generates only the necessary conversions, avoiding the runtime overhead associated with converting to and from intermediate formats. A performance comparison between the step-by-step approach used by im2im and a single-function approach demonstrates that the overhead introduced by im2im does not impact practical usability. While focused on block-based VPLs, im2im can be generalized to other VPLs and textual programming environments. Its principles are also applicable to domains other than images. The source code and analyses are available via GitHub.
@article{paperbot2897,
title = {im2im: Automatically Converting In-Memory Image Representations using a Knowledge Graph Approach},
author = {Fei Chen and Sunita Saha and Manuela Schuler and Philipp Slusallek and Tim Dahmen},
journal = {Proceedings of the ACM on Programming Languages},
volume = {9},
number = {OOPSLA2},
year = {2025},
doi = {10.1145/3763059}
}