=Paper= {{Paper |id=Vol-3867/paper1 |storemode=property |title=Resource Aware Implementation of Image Processing Algorithms - A Teacher Perspective |pdfUrl=https://ceur-ws.org/Vol-3867/paper1.pdf |volume=Vol-3867 |authors=Petar Rajković,Dragan Janković |dblpUrl=https://dblp.org/rec/conf/raw2/RajkovicJ24 }} ==Resource Aware Implementation of Image Processing Algorithms - A Teacher Perspective== https://ceur-ws.org/Vol-3867/paper1.pdf
                                Resource Aware Implementation of Image Processing
                                Algorithms – A Teacher Perspective
                                Petar Rajković1, ∗, †, Dragan Janković1, †
                                1 University of Niš, Faculty of Electronic Engineering, Aleksandra Medvedeva 14, Niš, Serbia



                                                  Abstract
                                                  Teaching image processing algorithms is a widely interesting and easily accepted topic by students.
                                                  The mentioned algorithms offer initial visual results, a lot of space for improvements, personal
                                                  initiative, and the opportunity for continuous work. This paper presents our experience in teaching
                                                  image processing algorithm implementation with different approaches, emphasizing concepts of
                                                  resource awareness. The programming routines explained to the students start from a managed
                                                  environment with and without dedicated classes and packages, through the unsafe code execution
                                                  up to native code integration. The paper presents the comparison of time utilization, programming
                                                  effort, and the level of the concept adoption by the students. The analysis was based on the student
                                                  projects uploaded to the learning management system in the period from 2018 to 2024. The results
                                                  are used to adjust the course structure and better adopt resource awareness-related concepts. The
                                                  percentage of projects entirely based on more effective approaches rose from 44% in 2018 to 80% in
                                                  2023 and 2024. During the monitored period, the overall average execution time of the benchmark
                                                  algorithms was reduced closely to one-third compared to the results from 2018, which follows the
                                                  shift towards more effective approaches. In this way, we tend to say that it is important to point out
                                                  all the technology benefits and shortcomings and to encourage students to try to find more effective
                                                  ways to solve time and resource-consuming problems.

                                                  Keywords
                                                  Image processing algorithms, resource awareness, execution efficiency 1



                                1. Introduction                                                The result should be a well-defined engineering course
                                                                                               and a properly suited set of requirements for the projects
                                Implementation of image processing algorithms is               that should be implemented by the students.
                                considered a remarkably interesting part of computer               One of the well-known approaches, that we used as
                                science [1]. Many students and programmers genuinely           the starting point, is to create an environment with basic
                                like this topic since it gives results that can be verified    methods and interfaces that will allow students to
                                quickly and visually.                                          implement their algorithms as plugins [4]. This
                                    To learn about image processing, a variety of              methodology typically favors technologies that enable
                                sources are available through different books, papers,         rapid implementation, such as Java or C#, with the
                                and tutorials. Looking at Google Scholar, it could be          objective being to grasp complex algorithms. In our
                                realized that standard learning resources like [2] and [3]     scenario, we present students with a project that
                                are cited several thousand times. Furthermore, the topic       includes fundamental functionalities and an application
                                offers particularly good ground for students’ further          framework, yet they retain the liberty to develop their
                                development and research.                                      applications from the start.
                                    Teaching image processing itself, is also an                   Since we teach the course in the eighth (final)
                                interesting challenge. It is important to find a suitable      semester of bachelor studies, we tend to move the focus
                                approach in terms of the used technology, offered              of the subject to more efficient programming, while
                                frameworks, and teaching methods. All this should              basing the course outline on the standard image
                                consider previous students’ knowledge and experience.          processing algorithms that could be practically used, as


                                3rd workshop on Resource AWareness of Systems and Society            0000-0003-4998-2036 (P. Rajković); 0000-0003-1198-0174 (D
                                (RAW 2024)                                                        .Janković);
                                ∗ Corresponding author.                                                         Copyright © 2024 for this paper by its authors. Use permitted under
                                † These authors contributed equally.                                            Creative Commons License Attribution 4.0 International (CC BY 4.0).

                                   petar.rajkovic@elfak.ni.ac.rs (P. Rajković);
                                dragan.janković@elfak.mi.ac.rs(D. Janković);




CEUR
                  ceur-ws.org
Workshop      ISSN 1613-0073
Proceedings
in [5] and [6]. The idea of focusing on real-life effects,         For this reason, we choose one possible approach
such as execution speed, was taken from [5], while             that could bring the best of both worlds, with the
topics from the research shown in [6] helped in forming        technology that offers a combination of both execution
the curriculum.                                                speed and fast developments, in the parts where each of
    On the other hand, the image processing algorithms         the approaches has its value [14].
are interesting from the point of view of execution                At the same time, we do not post any limitations to
optimization and general resource awareness, using             the students for the technology choice, but advocate
different techniques and approaches [7][8].                    implementation approaches that result in the code that
    In this study, emphasis is placed on examining the         executes faster. However, in this paper, four different
students’ execution of image processing algorithms and         implementation approaches, which are presented to the
their propensity to adopt various resource-aware               students during the course, are compared by the
strategies to enhance performance in their projects.           execution and development speed, with a set of
Besides the execution of complex algorithms constitutes        guidelines on how to use them.
a component of the curriculum at the bachelor’s,                   The mentioned approaches are used by the students
master’s, and doctoral study levels. This analysis             for the implementation of various categories of image-
concentrates on a cohort of final-year bachelor’s degree       processing algorithms, as part of their projects. Data
students who undertake image processing algorithm              collected over several years are examined to identify the
implementation as part of their Multimedia Systems             student’s responses to the use of the different
course. [9].                                                   implementation approaches.
    To implement some operations on digital images,                The study shows that students are willing to adopt
they must be stored in the form of a matrix of pixels [1].     implementation approaches that are more complex,
The operation should run through the matrix and                from the point of view of the implementation, up to
perform some calculations for each pixel. To describe          some point, for the benefit of faster code execution.
the importance of resource awareness in image
processing, let us analyze the processing requirements         2. Course Environment and
for the simple invert operation [3]. Invert operation is
replacing every byte in the picture with its
                                                                  Project Implementation
complementary value. I.e., if one byte in the original         It should be noted that each student that attended our
picture has a value of 30, in the inverted picture it will     course, hails from the Department of Computer Science
have a value of 225. The inverted value is calculated as       and is presently in their final semester. Throughout their
the difference between the maximal value for a byte and        academic journey, they have uniformly completed a
the original value.                                            foundational curriculum encompassing algorithms,
    If the image, where we perform the invert operation,       mathematics, as well as programming environments and
has a resolution of 1000x1000 pixels, and three bytes per      technologies. Consequently, there exists no subset of
pixel (standard 24bRGB format [10]), this means that           students possessing a disproportionate advantage in
three million operations need to be performed to create        terms of prior knowledge. Prior to commencing our
the inverted image.                                            course, they have garnered experience with
    If we observe today's image resolution, which is far       programming languages such as C++, Java/C#, in
more than one million pixels, it is obvious that image         addition to various Web and Mobile technologies.
processing must be implemented carefully and                        The example project environment is set up to
effectively. Looking at the side of the story related to the   Microsoft .NET Windows Forms application [11]. Such
execution speed, the obvious direction is to go towards        setup is advocated by the fact that the technology has all
the implementation in the programming environment              the prominent features of object-oriented design (similar
closest to the processor and operation system’s core.          to Java in [4]), is constantly developed, and has a fully
    Unfortunately, such environments are not usually           integrated development environment offering the
user-friendly and not convenient for the one-semester          possibility to build user interfaces fast and debug
course teaching where students must finish their tasks         efficiently.
and learn as much as possible. On the other hand, the               Like Java, .NET is the environment that runs on a
environments based on the execution of virtual                 process virtual machine [12]. In that sense, it offers
machines, such are Java and .NET offer high                    higher security for the end-user in terms of garbage
programming flexibility and user-friendly interface            collection, exception handling, and managed code
which makes the work on the project much faster.               execution. The downside of this approach is slower
Unfortunately, the execution speed in such                     execution.
environments is much slower than with native code.
                                                                    Processing based on the native code, in the
                                                                     unsafe block, which runs through the managed
                                                                     environment.
                                                                    Processing based purely on a native code,
                                                                     written, and evaluated in an external execution
                                                                     environment, and then brought to the
                                                                     managed       environment       using     COM
                                                                     (Component Object Model) interface and
                                                                     runtime-capable wrapper.

                                                                As presented in Figure 2, the source code, crafted in
                                                            .NET languages such as C#, is initially translated into
                                                            intermediate or bytecode. Subsequently, this bytecode is
                                                            compiled into the final executable. In contrast, unsafe
Figure 1: Method with an unsafe block.
                                                            code bypasses the intermediate code stage and is
                                                            compiled directly into the executable. Additionally,
         Source code                                        integrated calls to native libraries are executed directly
 (any language supported by        Unsafe Source Code       in the executable code, leveraging the capabilities
       .NET Framework)
                                                            provided by the COM interface.

                                                            2.1. Course and Project Outline
                                                            The curriculum is delivered over the spring semester,
                                                            spanning 14 working weeks, and encompasses a variety
         MSIL Code
                                                            of topics related to image processing. In the initial
                                                            stages, students become acquainted with various color
                                                            models, image file formats, and techniques for reducing
                                Runtime Capable Wrapper
                                                            image size, including downscaling and compression
                                                            methods.
                                                                 Subsequently, the course curriculum introduces
                                                            students to a range of image processing algorithms,
                                                            including fundamental filters (such as brightness,
       Executable Code                                      grayscale, contrast, gamma correction, and others),
                                                            dithering techniques, convolution, and displacement
                                                            filters. Furthermore, advanced subjects are explored,
Figure 2: Integration of managed and unmanaged code         encompassing histogram-based methods and intricate
(as described in [12])                                      filters like the Kuwahara filter. [13].
                                                                 When teaching image processing algorithms we
    To overcome this issue, the application requires a      focus on three major points – algorithm
higher execution speed, the .NET framework offers the       construction/correctness, variants and similar filters,
concept of unsafe code execution [14] which allows the      and execution efficiency. In most cases, execution
programmer to write native C++ code into a managed          efficiency is more important than memory use, since
environment directly (Figure 1). Furthermore, unsafe        many algorithms are built around additional data
allows full pointer level memory access without             structures which cannot be avoided during the
restriction. The unsafe code is written under a specific    implementation.
block starting with the keyword unsafe.                          As mentioned, the focus of our course is execution
    Also, .NET offers the possibility to directly include   analysis. Since we expect that students implement
libraries written in native code, as in any other           algorithms efficiently, from the algorithm flow’s point
programming environment, which is supposed to run as        of view, we display the differences in the execution
fast as possible. To support lectures, the following        depending on the chosen technology.
implementation modes are presented to the students.              The students are then able to measure in the demo
Namely:                                                     filters differences in the execution speed between the
                                                            implementation in different technologies and directly
         Raw data processing through managed code          experience trade-offs between comfort programming
         Included capabilities of framework classes        environments (such as C# and Java), and execution
          (managed code)                                    speed in native code implementation (C++).
    Since the execution time is one of the most              Project element      Maximal Correctness Execution
important factors in the eventual grade (14 out of 30                              points               time
points), students could decide whether pays off if they        Application           2         2         n/a
invest more time in a faster solution (Table 1).                structure
    Over the years, we slightly adapted the project          Downsampling             4            2            2
structure, taking into consideration results from the         Compression             4            1            3
previous years. The current project structure consists of:     Basic filter           2            1            1
         Image processing application that can load          Convolution             5            2            3
          standard file formats and display changes after         filter
          applying image transformation.                      Displacement            5            3            2
         Defining own file format by implementing                filter
          down sampling and compression                      Advanced topic           6            3            3
         Implementation of one basic filter                  Code quality            2            2           n/a
         Implementation of one dithering method (like             Total             30           16            14
          convolution filters)
         Implementation of one displacement filter
         Additional advanced filter implementation          Table 2
                                                             Examples of project composition between different
    During this time, we kept the project complexity         years (Project elements: B – basic filter, C – convolution-
requirements at the same level. The basic requirement is     style filter, D – displacement filter, A – advanced topic)
to implement a user-friendly application that will            Project            2018             2021           2024
display, at any point, original and changed pictures, and     element
to allow the user to save the effect of transformation
                                                                 B             Gamma            Grayscale     Contrast
either to some standard or to a custom file format.
                                                                 C           Edge detect        Sharpen       Dithering
    From year to year, we are changing requirements
                                                                 D             Pixelate        Time-Warp       Water
in terms of classes of implemented algorithms as well
                                                                 A          Trans-domain       Histogram      Kuwahara
as the definition of the file format. The projects from
one year exclude combinations of algorithms
implemented in previous years, but the general                   The students upload their projects in Moodle (until
requirements remain at the same level. For example, this     2020) and Teams (2021 onwards). After that, we execute
year (2024) the students had to convert RGB pictures to      them in the referent environment and with a referent set
YUV models and then apply some downsample scheme             of images and assign points for each project item. We
as in JPEG (4:2:0, or 4:1:1, etc.). After downsample, they   evaluate both algorithm correctness and execution
had to implement some of the dictionary based lossless       speed. In all these years evaluation has been done only
compression algorithms like Huffman or Shannon-Fano.         by the authors of these papers, which, we believe,
Table 2 shows the requirements for filters in three          ensured the same level of assessment. In this work, we
different years.                                             are focused only on execution time. Since the student
    This year students had to implement contrast as the      applications execute a single algorithm at a time,
basic filter, where different variants will be applied to    memory usage and scalability are out of the scope of
different group of students. Similarly, for the              their projects. In the same semester, they have different
convolution style filter, dithering was the theme for        course (Distributed systems) where the main aim is on
2024, where each group should implement its specific         scalability and robustness).
variant (like Jarvis, Stucki, Sierra, etc.).
    When we look in the Table 1, each project element        2.2. Raw Data Processing
comes in two to five variants, giving us more                Raw data processing is the basic way to process images
combinations than the students, which means that every       (Figure 3). The programmer should load an array of
student will have a unique project. I.e., in 2024, we had    bytes from the file and transform them into a meaningful
4 downsampling variants, 2 compression algorithms, 3         data structure. The complexity of this task depends on
contrast variants, 4 dithering filters, 3 variants of        the file type. For example, uncompressed files like
displacement filter, and 2 different advanced topics,        bitmaps could be directly loaded and converted, while
which makes 576 different variants for less than 100         compressed files, like JPEGs and PNGs, must be
students.                                                    significantly processed.
Table 1
General point distribution scheme and criteria
                                                               Once, the image is loaded and converted to a bitmap
                                                               object, each pixel can be accessed by GetPixel method.




                                                               Figure 4: Method invert written in managed code with
                                                               supporting Bitmap class and Color structure.

                                                                   This method returns an instance of type Color with
                                                               Red, Blue, Green, and Alpha components. These values
                                                               could be then processed, and new color values now
                                                               could be written back to the Bitmap object. From the
Figure 3: Method invert written as raw data processing.        logical point of view, the programmer must focus only
                                                               on the implementation of processing algorithms,
      For bitmaps [15], every byte has its meaning, and the    without the need to take care or pay attention to any
corresponding piece of information could be extracted.         other task in the scope of image processing.
I.e., in the presented example, 4 bytes started at position        On the other hand, this approach runs fully under
10 in the file defining image height and the next 4 image      managed code, and it is the slowest way of
weight. The bytes starting from position 54, for images        implementation. One can say that the programming
stored as 24b RGB files, define the image, and knowing         comfort is paid by the slowest runtime.
that each pixel is described by three bytes makes the              Development using the provided framework classes
image processing straightforward.                              [16] is the easiest from the programmer's point of view
      The implementation based on raw data processing is       (Figure 4). With the simple call of the single method, the
suitable only for plain bitmap files since they contain        programmer will have a completely structured image
directly stored pixel-related data. This approach requires     converted to a bitmap object with all the features and
no additional data structures and classes and could be         properties directly exposed. The downside of this
implemented using the programming language basics              approach is that the code execution is the slowest. The
only. In this sense, it requires a bit more organization of    execution time is directly proportional to the size of the
the processing and it could be suitable for the filters with   image, and additional time will be spent on locking and
simpler implementation. This approach could be used in         unlocking the memory area for every single execution
any programming language, and if properly                      of SetPixel function.
implemented, could give excellent execution                        The calls of the methods that should get or set the
performance.                                                   pixel value must go through the execution virtual
                                                               machine and must ensure necessary locking
2.3. Processing Based on Framework                             mechanisms each time. The recommendation for this
        Classes                                                approach is to be used in the initial stage of the projects
                                                               where the students are setting up their environment and
For the most effective use, the framework classes could
                                                               learning the process of image processing itself. This
be utilized. The most important class for image
                                                               approach could be used if the expected size of the picture
processing is the class Bitmap inherited from the more
                                                               will not exceed certain limits, and if it will be used for
common class Image [16].
                                                               previews since they could be easily integrated into Web
    This class offers the easiest, from the programming
                                                               routines and technologies such as Blazor.
point of view, approach. The programmer loads a
picture of any supported type using the Load method.
2.4. The Use of Unsafe/Native Code
There are two options to use unsafe/native/non-
managed code. First, the programmer could write a
method in the native language library and then include
the library in the project (Figure 5). The problem with
this approach is that debugging of such code should be
done in some programming tool, different from the
environment where the main application is written.




Figure 5: Declaration of the external function written in
native code.

    It is important to point out that such an approach is
not a problem per se during the development of real
software systems, but for student projects whose
duration is very limited, and where students have to
cope concurrently with the additional tasks, learning to
use multiple environments could be a challenge up to
some point.
                                                            Figure 6: Method invert written in unsafe code.
    To have the best of both worlds – managed and
unmanaged code, the students are encouraged to use               The approach with an unsafe code execution is the
unsafe blocks in the Windows Forms application [18].        fastest way to perform image processing from the
This approach is not common for other development           managed code environment. It is up to some percent
environments, such is Java, and it is considered more       slower combined with direct native applications, but the
like an additional than the technology standard.            comfort of the integrated development seems justified as
    Working in the unsafe block is close, if not equal to   the acceptable price.
writing code in the native, C++ environment. The                 As can be seen in the previous section .NET
programmers have under their disposal, complete             environment offers adequate transformation classes that
pointer arithmetic with the additional requirements to      help in moving the execution context from managed to
transform data types from .NET to native classes, and to    unmanaged. Keeping in mind that the application
take care of garbage collection.                            development, in the case of the student project, relates
    The implementation of the invert operation in an        to tight deadlines such an approach proved its value.
unsafe environment is displayed in Figure 6. To support
the coding, programmers could use BitmapData [17]           2.5. Brief on Implementation
class and its properties. Conversion from Bitmap to                  Approaches
BitmapData is done using LockBits and UnlockBits
methods, which ensure, in addition, uninterrupted               As it could be seen each of the approaches has its
memory management. The area of memory that stores           benefits and drawbacks. While raw data processing
raw image bytes will be safely locked before the            requires no additional libraries and frameworks, it
processing moves to an unsafe environment and then          requires more attention to organize code, and it is not
unlocked when the program flow returns.                     useful for complex image types.
                                                                      The only programmer required to translate
                                                                      managed to native code.
                                                                     Convolution filters – the filters where the
                                                                      values of neighboring pixels affect the
                                                                      currently processed pixel. Compared to basic
                                                                      filters they require significantly more
                                                                      processing, but a similar amount of memory
                                                                     Displacement filters – require additional data
                                                                      structure which needs a comparable amount of
                                                                      memory as the processed image. Compared to
                                                                      basic filters they require more memory and
                                                                      more processing operations




Figure 7: An example of the demo picture used for filter
evaluation, taken from the Bing wallpaper site
https://bing.gifposter.com/au/column-41-container-
ship-near-a-commercial-port-in-thailand.html, and then
cropped to 2000x2000

     Relying only on the framework based on managed
code will speed up the development process, at the price
of the slowest execution. The integration of externally
developed algorithms brought the fastest execution, but
the development must be split between multiple
projects, development tools, and programming
languages. It requires the highest amount of time for
development.
     The approach based on the unsafe code seems like a      Figure 8: Example of applied contrast filter.
promising approach for student projects focused on
image processing algorithms. It offers performance close     3.1. Basic Filters
to the native code, seamless integration of the native
code in the managed environment, and higher memory           As has been mentioned, basic filters are those that
efficiency since it enables precise memory management.       require one pass through the matrix of pixels with an
The drawbacks of this approach are the same as with the      optional parameter transformation. For our evaluation,
native code execution - higher potential for bugs and        we choose a contrast filter (Figure 8), which is an
higher complexity for maintenance [18]. The images           example of a common filter with many specific variants
used for the evaluation are in resolution of 2000x2000       depending on the area of the application [19]. Aside
pixels (Figure 7) and higher with different aspect ratios    from this one, the students had a few more as part of the
and color representation.                                    task - brightness, color, gamma, grayscale, and
                                                             conversion to distinct color models [20] – like luma-
                                                             chroma (or YUV) or hue-saturation-value (HSV).
3. Classes of Image Filters for
   Demo                                                      3.2. Convolution Filters
For the application of the mentioned approaches, the         Unlike the basic filters, the convolution filters use the
students have the task of implementing several image         auxiliary matrix structure, usually called the kernel. The
filters from the various categories. To make the most        kernel is a matrix of small size, in most cases 3x3, and is
convenient test cases, three diverse types of filters are    set up with predefined parameters. In addition, the
checked:                                                     convolution filter has two more values - factor and
          Basic filters – their implementation requires     offset. Some of the example of convolution matrices are
           only iteration through all pixels in the image.   presented in Figure 9.
Figure 9: The examples of convolution filters with
corresponding kernel matrices, offset, and factor values.

                                                              Figure 11: Example of displacement time warp filter.

                                                                   The number of operations needed to perform the
                                                              convolution filter is significantly higher than with basic
                                                              filters. We can assume that during basic filter execution,
                                                              the number of performed steps is the multiplication of
                                                              the image resolution, for the convolution filters it is a
                                                              multiplication of the image resolution and number of
                                                              elementary operations connected with a chosen kernel
                                                              matrix. For example, the execution of a sharpened filter
                                                              (Figure 10) will execute ten times (nine multiplication
                                                              and division with the factor value) more operations than
                                                              the execution of a basic invert.

                                                              3.3. Displacement Filters
                                                              Displacement filters are based on a pre-built
                                                              transformation matrix which is the same size as the
Figure 10: Example of the applied convolution filter          targeting picture (Figure 11). Their execution is split
                                                              into setup and execution phases. In the setup phase, the
     The processing works in a way that the submatrix,        transformation matrix is created using some algorithm,
of the same size as a kernel, from the picture, should be     and in the execution phase, the values from the
extracted. The value of each pixel from the extracted         transformation matrix are combined with the pixel
matrix is multiplied by the corresponding parameter in        values from the picture to achieve the desired effect.
the kernel. All these products are then summed up
together, divided by the value provided for factor, and       4. Discussion on Students'
on top of this value is added offset.
     The values in the matrix are important for the              Response
filtering operation itself, while the values for factor and   We have been teaching courses that partly cover image
offset are used to normalize the sum of products into the     processing for longer than a decade and a half. Image
required value range. In our case, these are the values       processing was taught as a part of courses such are
that could be stored in one byte (0 to 255).                  Algorithm Complexity, Multimedia Systems, Secure
                                                              Software Design, Medical Imaging, and Medical
                                                              Informatics. These courses were conducted on diverse
                                                              levels of studies with different complexity and structure
                                                              of the student projects.
                                                                  Depending on the subject, we used to point out
                                                              different elements of the image processing. Somewhere
                                                              the focus is on the algorithm design, somewhere on the
integration in large-scale systems, somewhere on a                Data in Table 2 and Table 3 show the project
minimal alteration of the existing algorithms with a          distribution per technology. The projects, by the
focus on the execution performance. For the evaluation        implementation technology of image processing
of different programming approaches, we used the              algorithms, could be categorized into four major
subject of Multimedia Software Systems – an electoral         categories – managed, native, unsafe, and other. Projects
course in the fourth year of bachelor study. In the           developed in .NET and Java are considered managed
evaluated period, the number of students was in the           code-based projects.
range from 32 to 70 (2018 57, 2019 35, 2020 44, 2021 47,          The projects marked as “native” are those whose
2022 50, 2023 49, 2024 70).                                   algorithms are developed in various C++ environments,
    The image processing software project is one of the       regardless of the technology used for the front end. In
assignments in the course, and the requirement is to          the category unsafe are these that follow the suggestion
implement several image processing algorithms of              to include unsafe code blocks in managed projects.
different complexity with minimal use of processing           Category other is for the projects implemented in
power and memory. For the test, the students must             various Web technologies with different approaches
create an application that is comparable to Windows           considering implementations of algorithms both in the
Forms in a .NET environment which can immediately             front and back end, using technologies such are various
display the result after processing is finished.              JavaScript-based frameworks.
                                                                  After the students uploaded their projects in the
Table 3                                                       collaborative learning platform, initially it was Moodle
Number of students who finished complete project.             and later switched to Microsoft Teams, the projects were
  Year    Number of enrolled Students who finished            checked for performance in the demo machine to verify
              students          complete project              against the same conditions. The demo machine is an
  2018           57                45 (79%)                   Intel-based i7-8550U running at 1.8 GHz with 4 cores
  2019           35                22 (63%)                   and 8 logical processors, supported by 16GB of RAM. It
  2020           44                29 (65%)                   is important to point out that all projects from the year
  2021           47                39 (83%)                   2018 until now are run and evaluated under the same
  2022           50                41 (82%)                   conditions.
  2023           64                58 (90%)                       The Intel processors which mark ends by the sign U
  2024           70                61 (87%)                   are not designed primarily for speed, but rather for
                                                              energy efficiency. In that sense, such a computer is the
                                                              perfect environment for the execution demo since the
    The only limitation that students have is related to      differences are better displayed.
the user interface which has to be fast and responsive            The obvious benefit of using native and unsafe
and allow the display of the processed image. There is        approaches can be seen in Table 6. Comparing execution
no specific request for a certain technology, besides, we     time between native and unsafe approaches shows that
advocate Microsoft .NET. On the other hand, there are         native code runs 10 to 20 percent faster. The exact time
no limitations to the implementation of image                 varies depending on which moment of implementation
processing algorithms themselves.                             students brought unsafe mechanisms to the project. For
    Table 3 shows the number of enrolled students per         those that start with unsafe functions during data
year together with the number of students who                 loading, the results are better than those that use unsafe
successfully finished the entire project. Excluding the       mechanisms only for the algorithm execution.
years 2019 and 2020, where the lectures were conducted            The significant difference is between unsafe and
in online mode, the percentage of the students who            managed code. The difference is in dozens of
finished the projects was above 80%. During the period        multiplications. Figure 12 shows that the difference is
of online classes, this percentage dropped to less than       such, that the logarithmic scale could be easily employed
two-thirds.                                                   to display the difference. Other approaches, based on
    In the previous year (2023) we made a slight change       different Web technologies demonstrate the worst
in course organization by moving the image processing         results in the sense of the execution time. Based on Web
project to be the last in the row, as we considered it more   technology, the disadvantage is that considerable time is
complex. This gave the students the possibility to work       required to upload the source picture and then to
on it in a period where they had fewer overall tasks          download the results, which, makes the situation worse.
during the school year. This resulted in the highest              What could be seen, during the years, is that
percentage of successfully finished projects at 90%. This     students accept the resource awareness narrative at a
year, we will follow the same approach, and, at the           high percent. Besides the higher popularity of Web
beginning of June, we will have complete data for 2024.       applications and JavaScript-based frameworks, this
approach was not the dominant choice to manage image        2023        8           12          9           8
processing problems.                                        2024        7           13          8           9

Table 4
Distribution of technology used in successful student
projects.
 Year    Managed      Native     Unsafe       Other
 2018      21           8         12            4
 2019      14           2          6            1
 2020      17           4          6            2
 2021      10          11         13            5
 2022       6          12         17            6
 2023       8          17         27            6
 2024      11          12         31            7

Table 5
Distribution of technology used in unfinished student
projects.
 Year    Managed      Native     Unsafe       Other        Figure 12: Comparison of relative execution times for
 2018       1           5          2            4          simple, convolution, and displacement filters.
 2019       3           3          4            3
                                                               Student projects are set up for three weeks, which
 2020       7           5          3            1
                                                           makes 15 days the maximal amount of time needed for
 2021       0           4          1            3
                                                           the execution. During the project, students must
 2022       1           6          0            2
                                                           implement several filters that belong to various
 2023       1           2          1            2
                                                           categories. The filters that should be implemented are
 2024       4           1          2            2
                                                           changed each year. Besides that, the overall project
                                                           complexity tends to be kept, in the teachers’ opinion, on
    Projects predicated on managed code predominated       the same level.
in 2019 and 2020, coinciding with the period when              Table 7 and Figure 13 show an insight into how
lectures were delivered online. With the resumption of     many days students were active on the project. These
conventional in-person lectures and the enhancement of     numbers represent the difference between the dates
interactive, hands-on laboratory demonstrations, there     when students downloaded the assignment and the
was a discernible shift in preference towards approaches   dates when the solutions were submitted. This is not the
that are more efficient in terms of performance.           best conceivable way, since there is no exact way to
                                                           prove the correctness of this approach, but, on the other
Table 6
                                                           hand, there is no morally acceptable way to measure
Average execution time by technology in benchmark
machine for default image of 2000x2000 resolution in       how much time students spend working on their
milliseconds                                               projects. Optionally the survey could be created, but the
                                                           answers could be disputable either.
 Approach        Simple Convolution Displacement
Managed C#       2054.77  6810.82     15490.77
Managed Java     2955.41  8191.38     18927.35
  Native          35.41    124.77      450.20
  Unsafe          39.61    146.76      559.44
   Other         4850.66 11843.17     41817.93

Table 7
The average number of working days that student
needed for implementation.
 Year    Managed      Native     Unsafe       Other
 2018       7          12          8            9
 2019      11          10         10           15
 2020      10          11         12           15
 2021       7          13         10           11
 2022       6          14          9            8
Figure 13: Comparison of relative programming effort          completely managed approach could be in most cases
between different programming approaches through              optimal way.
observed years.                                                   However, each of the presented approaches has its
                                                              pros and contras, and depending on the type of the
    Nevertheless, several observations can be discerned.      projects, domain of usage, and the expectations
Primarily, students who commence their assignments            regarding performance and memory usage, could be
late tend to opt for a managed solution or a JavaScript-      voted as optimal. In any case, future programmers must
based framework, as these approaches necessitate less         have a good overview of all the options and be aware of
time investment. This trend was particularly                  the appropriate use for the most valuable resource they
pronounced during the years 2019 and 2020 when                choose – either development time or the use of the
instruction was conducted in an online format.                execution resources.
    Most unsuccessful solutions were developed using              In this context, we posit that the incorporation of
the native code, which is logical given its demand for        resource-awareness principles into the educational
more time and advanced programming expertise.                 curriculum is crucial, particularly in the concluding year
Additionally, it is noteworthy that the greatest failure      of study. Our research advocates for an instructional
rate was observed in the “other” category. This may be        approach in image-processing education that utilizes
attributed to students’ lack of sufficient familiarity with   managed code examples instead of pseudocode for
technologies that appeared promising, yet they lacked         algorithmic elucidation during lectures. Concurrently,
adequate experience to utilize them effectively.              laboratory exercises should employ unsafe and
    An unsafe approach seemed like a good balance. It         unmanaged code to elucidate the disparities in execution
offers the possibility to start with the managed              velocity, which can be significant in certain instances.
approach, reach some point in implementation, make                Through this paper, our objective is to convey that
the proof concept of all the algorithms, and then convert     while numerous contemporary technologies offer
only parts of the project to the native code. Besides the     considerable programming convenience and efficient
approach being heavily technology-dependent and even          development at the business layer, they should not be
not easily portable, it is a good example of the hybrid       indiscriminately adopted as a panacea for all
approach in development and how this kind of approach         programming       challenges.      Instead,    prospective
could bring overall benefits.                                 developers must meticulously analyze the specific
    For an average of 15% more time than needed than          problem domain and judiciously select appropriate
for the projects based on managed code, the output runs       technologies for each component therein.
only 10% slower compared to the projects in which
image processing algorithms are entirely built in the         Acknowledgments
native code. Ignoring years 2019 and 2020, the average
time needed for the native approach is around 50% more        The Ministry of Science, Technological Development
than with the managed code.                                   and Innovation of the Republic of Serbia supported this
                                                              work [grant number 451-03-65/2024-03/200102].
5. Conclusion                                                 This work is partially supported by the cost action CA
                                                              19135 CERCIRAS (Connecting Education and Research
Bringing the concepts of general resource awareness in        Communities for an Innovative Resource Aware
programming is yet again important. Besides the rising        Society).
popularity of fast-to-build and nice-to-look frameworks,
followed by the constant increase of processing power         References
and memory volume of all computational devices, one
cannot entirely rely on the easiest solutions.                [1]   M. J. Burge, W. Burger, Digital Image Processing:
    As could be seen with a managed approach in the                 An      Algorithmic     Introduction,     Springer
languages based on the execution virtual machine, the               International Publishing AG, 2022
two-line implementation could save time while                 [2]   J. R. Jensen, Introductory Digital Image
programming, but it will result in a fifty times slower             Processing, Third Edition (Prentice Hall Series in
overall execution.                                                  Geographic Information Science), 3rd. ed., Prentice
    The use of the native environment will, of course,              Hall, 2004.
bring the best possible results, but the price will be        [3]   B. Jähne, Digital Image Processing: Concepts,
significantly longer development phase. In that sense,              Algorithms, and Scientific Applications, Springer
the technology-specific solutions, like unsafe, could be            London, Limited, 2013.
an extremely good compromise between approaches.              [4]   D. Sage and M. Unser, "Teaching image-processing
Getting 10% worse results, compared to native code,                 programming in Java," in IEEE Signal Processing
with spending around 15% more time compared to a
       Magazine, vol. 20, no. 6, pp. 43-52, Nov. 2003, doi:    [17] BitmapData Class (System.Drawing.Imaging).
       10.1109/MSP.2003.1253553.                                    URL:                 https://learn.microsoft.com/en-
[5]    L. de O. Alves, L. F. Cruz, P. T. M. Saito, and P. H.        us/dotnet/api/system.drawing.imaging.bitmapdat
       Bugatti, "Towards Practical Computer Vision in               a?view=dotnet-plat-ext-8.0.
       Teaching and Learning of Image Processing               [18] G. Chobanyan, A Comprehensive Guide to Unsafe,
       Theories," 2019 IEEE Frontiers in Education                  Unmanaged Code and Pointers, 2023. URL:
       Conference (FIE), Covington, KY, USA, 2019, pp. 1-           https://itnext.io/a-comprehensive-guide-to-
       7, doi: 10.1109/FIE43999.2019.9028645.                       unsafe-unmanaged-code-and-pointers-
[6]    Gil, P., García, G. J., Puente, S. T., Mateo, C. M.,         b8e143867b3e.
       Alacid, B., & Mira, D. (2016). Teaching image and       [19] Hiary, Hazem, et al. "Image contrast enhancement
       video processing with a practical cases-based                using geometric mean filter." Signal, Image and
       methodology at the University of Alicante. In                Video Processing 11 (2017): 833-840.
       EDULEARN16 Proceedings (pp. 6067-6077).                 [20] Ibraheem, N. A., Hasan, M. M., Khan, R. Z., &
       IATED.                                                       Mishra, P. K. (2012). Understanding color models:
[7]    V. Monga, Y. Li, Y. C. Eldar, Algorithm Unrolling:           a review. ARPN Journal of science and technology,
       Interpretable, Efficient Deep Learning for Signal            2(3), 265-275.
       and Image Processing, IEEE Signal Process. Mag.
       38.2 (2021) 18–44. doi:10.1109/msp.2020.3016905.
[8]    J. Tang, G. Liu, Q. Pan, A Review on
       Representative Swarm Intelligence Algorithms for
       Solving Optimization Problems: Applications and
       Trends, IEEE/CAA J. Autom. SIn. 8.10 (2021) 1627–
       1643. doi:10.1109/jas.2021.1004129.
[9]    University of Niš, Faculty of Electronic
       Engineering, Course Catalog, English. URL:
       https://www.ni.ac.rs/en/studies-and-
       admission/studies/course-
       catalogue/courses?task=download.send&id=
       6594&catid=666&m=0.
[10]   RGB24 pixel format for digital imaging, URL:
       https://www.theimagingsource.com/en-
       us/documentation/icimagingcontrolcpp/Pixelfor
       matRGB24.htm.
[11]   Windows Forms for .NET 7 documentation. URL:
       https://learn.microsoft.com/en-
       us/dotnet/desktop/winforms/?view=netdesktop-
       8.0.
[12]   Managed Execution Process - .NET. URL:
       https://learn.microsoft.com/en-
       us/dotnet/standard/managed-execution-process.
[13]   Bartyzel, Krzysztof. "Adaptive kuwahara filter."
       Signal, image and video processing 10 (2016): 663-
       670.
[14]   Unsafe code, pointers to data, and function
       pointers            -            C#.            URL:
       https://learn.microsoft.com/en-
       us/dotnet/csharp/language-reference/unsafe-
       code.
[15]   Bitmap Image File (BMP), Version 5. URL:
       https://www.loc.gov/preservation/digital/formats
       /fdd/fdd000189.shtml.
[16]   Bitmap       Class      (System.Drawing).       URL:
       https://learn.microsoft.com/en-
       us/dotnet/api/system.drawing.bitmap?view=dotn
       et-plat-ext-8.0.