Viewing and Converting Graphics Files

Lecture



Image viewing tools.

Image viewing tools fall into several types depending on their functionality and the file formats they support. Here are the main categories and examples:

1. Built-in tools

  • Windows Photos — the standard image viewer application in Windows.
  • Preview — the analogous application for macOS.
  • GNOME Image Viewer (Eye of GNOME) — the standard viewer in Linux (GNOME).
  • KDE Gwenview — for the KDE desktop environment in Linux.

2. Free programs

  • IrfanView — a lightweight, fast viewer supporting a wide range of formats.
  • XnView — a powerful tool for viewing, editing, and converting images.
  • FastStone Image Viewer — a convenient tool with extensive features, including basic editing.
  • Nomacs — a cross-platform, open-source viewer.
  • ImageGlass — a modern, fast, and minimalist viewer for Windows.

3. Viewers for professional formats

  • ACDSee — supports rare formats and offers tools for managing an image library.
  • Adobe Bridge — a convenient viewer and organizer for professional photographers.
  • STDU Viewer — a universal viewer for rare formats such as TIFF, DjVu, and PDF.

4. Online services

  • Google Photos — supports cloud storage and viewing of images.
  • Photopea — a powerful online editor that can also be used for viewing.
  • Imgur or Flickr — for storing and quickly viewing images.

5. Viewers for CAD and technical formats

  • Autodesk Viewer — a viewer for engineering drawings and 3D models.
  • FreeCAD Viewer — for viewing models created in CAD systems.
  • DWG TrueView — a DWG file viewer from Autodesk.

6. Command-line tools

  • ImageMagick — a powerful tool for viewing and processing images from the terminal.
  • ffmpeg/ffplay — for quickly viewing image files, including video frames.

Software tools for mutual conversion of graphic files of various formats.

Software tools for mutual conversion of graphic files allow images to be converted from one format to another. Such tools can be either universal (supporting many formats) or specialized (working with a limited set of formats). Here is a list of popular solutions:

1. Universal converters

These programs support a wide range of formats and provide a convenient interface for batch processing:

  • XnConvert
    A universal image conversion program. Supports more than 500 input formats and 80 output formats. Suitable for batch processing.

  • IrfanView
    A lightweight and functional viewing and conversion tool. Supports plugins for rare formats.

  • FastStone Photo Resizer
    A convenient tool for resizing, converting, and batch-processing images.

  • Total Image Converter
    A program for working with most popular formats (JPEG, PNG, TIFF, BMP, RAW, and others).

2. Specialized converters

These tools are oriented toward specific tasks or formats:

  • RAWTherapee
    Designed for working with RAW files used in professional photography.

  • Adobe Photoshop
    A powerful tool for editing and converting images, supporting many professional formats, including PSD.

  • CorelDRAW
    Suitable for working with vector and raster formats such as AI, CDR, SVG, and converting between them.

  • GIMP
    A free graphics editor with advanced image conversion capabilities.

3. Online services

Suitable for quick conversion without installing software:

  • Convertio
    Supports most graphic formats. Works online, supports batch processing.

  • Online-Convert
    A universal tool for converting images, video, audio, and documents.

  • ILoveIMG
    A convenient online service for image conversion and basic editing.

4. Command line and scripts

For automating processes and working with large numbers of images:

  • ImageMagick
    A powerful command-line tool for working with images. The convert command allows images to be converted between formats.
    Example:

    bash
    convert input.png output.jpg 
  • GraphicsMagick
    A more optimized counterpart to ImageMagick.

  • ffmpeg
    Used for working with multimedia, but also supports converting graphic formats such as PNG, JPEG, and others.

5. Programs for working with vector graphics

If conversion of vector formats is required (for example, SVG, EPS, PDF):

  • Inkscape
    A free vector graphics editor. Can convert SVG to PNG, PDF, EPS, and other formats.

  • Adobe Illustrator
    A professional tool for working with vector images. Supports export to various formats.

6. Libraries and tools for developers

For programmatic image conversion:

  • Pillow (Python)
    A Python library for working with raster images.
    Example:

    python
    from PIL import Image
    img = Image.open("input.png")
    img.save("output.jpg") 
  • OpenCV
    Suitable for working with images and video, including format conversion.

  • Sharp (Node.js)
    A fast image processing library supporting popular formats.

Converting vector objects into a raster (bitmap) image.

Converting vector objects into raster (bitmap) images is called rasterization. This is the process by which vector data (described by mathematical curves, lines, and points) is converted into an image composed of pixels. The result is a file in a format such as PNG, JPEG, or BMP.

Tools for rasterizing vector graphics

1. Graphics editors

  • Adobe Illustrator
    A professional tool for working with vector graphics. Allows exporting vector files to raster formats.
    Process:

    1. Open a vector file (for example, AI, SVG, EPS).
    2. Select File → Export → Export As.
    3. Specify the format (for example, PNG or JPEG).
    4. Configure the resolution (ppi) and quality.
  • CorelDRAW
    Also supports export to raster formats.
    Process:

    1. Open a vector file.
    2. Select File → Export.
    3. Specify the format, resolution, and anti-aliasing settings.
  • Inkscape
    A free tool for working with vector graphics.
    Process:

    1. Open a vector image.
    2. Select File → Export PNG Image.
    3. Specify the resolution and export area (the entire document or a selected object).

2. Online services

For quick conversion without installing software:

  • Convertio
    Files in SVG, EPS, PDF formats are uploaded and then exported to PNG or JPEG.
  • Online-Convert
    Supports DPI, quality, transparency, and format settings.
  • Vectr
    An online editor with the ability to export to raster formats.

3. Programs for technical graphics

  • AutoCAD
    Supports exporting drawings (DWG, DXF) to raster formats such as TIFF and PNG.
    Process:

    1. Select Output → Plot or Export.
    2. Specify the format and resolution.
  • FreeCAD
    For working with technical 2D/3D models. Export to PNG via rendering with resolution settings.

4. Command line and automation

  • Inkscape CLI
    Convenient for bulk processing of SVG files.
    Command:

    bash
    inkscape input.svg --export-filename=output.png --export-dpi=300 
  • ImageMagick
    Used for converting vector formats to raster formats.
    Command:

    bash
    convert input.svg -density 300 output.png 
  • CairoSVG
    A Python library for rasterizing SVG.
    Example:

    python
    
    from cairosvg import svg2png
    with open("input.svg", "rb") as svg_file:
       svg2png(file_obj=svg_file, write_to="output.png", dpi=300) 

5. Settings for high-quality rasterization

  • Resolution (DPI)
    72–96 DPI is sufficient for on-screen display; 300 DPI or higher is recommended for printing.
  • Anti-aliasing
    Used to smooth the edges of objects, improving image quality.
  • Color model
    Use RGB for on-screen display and CMYK for printing.

Converting raster (bitmap) images into vector objects.

Converting raster (bitmap) images into vector objects is called tracing or vectorization. This process consists of converting an image's pixel information into mathematical descriptions of shapes (lines, curves, etc.) that can be scaled without loss of quality. This is especially useful for logos, illustrations, or other graphic elements that need to be modified without loss of quality.

Methods and tools for vectorizing images

1. Graphics editors

  • Adobe Illustrator (Live Trace)
    Illustrator offers a powerful "Image Trace" tool that automatically vectorizes raster images such as JPEG, PNG, or TIFF.
    Process:

    1. Open a raster image in Illustrator.
    2. Select the image and click the "Image Trace" button in the control panel.
    3. Configure the trace parameters (color, precision, number of colors, etc.).
    4. Click "Expand" to convert the trace paths into vector objects.
  • CorelDRAW (PowerTRACE)
    CorelDRAW has a built-in vectorization tool — PowerTRACE — similar to Illustrator's tracing function.
    Process:

    1. Open a raster image in CorelDRAW.
    2. Select the image and choose Bitmap → Trace Bitmap.
    3. Configure the trace parameters and click "OK".
    4. Edit the vector image as needed.
  • Inkscape
    A free, open-source vector graphics editor that also has a tool for tracing raster images.
    Process:

    1. Open a raster image (for example, PNG or JPEG).
    2. Select the image and go to Path → Trace Bitmap.
    3. Configure the trace parameters (modes, threshold values, number of colors).
    4. Click "OK" and save the result in a vector format, such as SVG.

2. Online services for vectorization

For quick vectorization without installing additional software:

  • Vectorizer (https://www.vectorizer.io)
    A simple online platform for converting raster images into vector formats.
  • Autotracer (https://www.autotracer.org)
    A free online tool for tracing raster images into SVG, EPS, and other formats.
  • Online-Convert (https://image.online-convert.com/convert-to-svg)
    An online converter that allows raster images to be converted into SVG or other vector formats.

3. Programs for technical graphics

  • AutoCAD
    The "Raster to Vector" tool can be used to convert raster images into vector formats (for example, DXF).
    Process:

    1. Open a raster image in AutoCAD.
    2. Use the Raster Design → Raster to Vector command to convert the image to vector form.
    3. Configure the trace parameters and save the result in DXF or another format.
  • FreeCAD
    For working with engineering graphics, raster images can be traced into vector objects using extensions and plugins.

4. Specialized vectorization programs

  • Vector Magic
    One of the best-known vectorization tools, delivering high-quality results. Works both online and as a desktop application.
    Process:

    1. Upload an image to Vector Magic.
    2. Select the trace parameters (precision, number of colors, etc.).
    3. Download the result in SVG, EPS, or PDF format.
  • Potrace
    A free, open-source program for tracing raster images into vector form. Has a graphical interface and is also available via the command line.

    Command line usage (Linux, macOS):

    bash
    potrace input.bmp -o output.svg 

5. Settings for high-quality vectorization

  • Brightness threshold
    During tracing it is important to set the brightness threshold correctly in order to properly interpret the areas of the image that should be converted into outlines.

  • Color palette
    When tracing color images, the number of colors to be used in the vector image must be specified. The more colors used, the more accurate the result, but it may become more complex and harder to edit.

  • Smoothing level
    For curves and lines, the smoothing level can be adjusted to minimize "jaggedness" during vectorization.

Main vector image formats

  • SVG (Scalable Vector Graphics) — the most widespread format for web graphics and vector images.
  • EPS (Encapsulated PostScript) — used in professional graphics and printing.
  • AI (Adobe Illustrator) — the format used in Adobe Illustrator for working with vector images.
  • PDF (Portable Document Format) — can contain both raster and vector elements.

Algorithms for vectorizing raster images

Several types of algorithms are used to convert raster (bitmap) images into vector objects. These algorithms perform tracing or vectorization of raster images, turning pixel information into mathematical shapes such as lines, curves, and polygons

Viewing and Converting Graphics Files

. The most common approaches include:

1. Contour tracing algorithms

These algorithms focus on extracting contours from raster images in order to convert them into vector objects.

1.1. Canny Edge Detection

The Canny algorithm is an edge detection method used to identify contours. It applies several steps: filtering with a Gaussian filter, gradient computation, non-maximum suppression, and thresholding to isolate true edges.

  • Application: Can be used as a preliminary step for subsequent vectorization.
  • Advantages: High accuracy in edge detection.
  • Limitations: Can be sensitive to noise in the image.

1.2. Sobel Edge Detection

This is a classic algorithm for finding gradients in an image. It computes changes in pixel intensity in the horizontal and vertical directions, which makes it possible to highlight contours.

  • Application: Contour detection for further vectorization.
  • Advantages: Simplicity and speed.
  • Limitations: Not as accurate as the Canny algorithm, especially on complex images.

1.3. Laplacian of Gaussian

This algorithm combines two stages: filtering the image with a Gaussian filter for smoothing, and applying the Laplacian operator to highlight contours.

  • Application: Preprocessing of images to highlight contours.
  • Advantages: Works well for images with low noise.
  • Limitations: Sensitivity to noise.

Viewing and Converting Graphics Files

2. Vectorization algorithms

2.1. Potrace (algorithm/toolset)

Potrace is one of the best-known toolsets for tracing raster images into vector shapes. It uses a method based on adaptive smoothing and curve optimization to produce smooth contours.

  • Application: Potrace is used to convert raster images (for example, BMP, PNG) into vector formats such as SVG.
  • Advantages: High tracing quality, especially for simple images such as logos or drawings.
  • Algorithm: Potrace uses an error-minimization method to optimize curves and smooth contours, giving good vectorization results.
  • Limitations: May not work as well for images with many details or complex colors.

2.2. Tracing algorithm using Bezier curves

An image tracing algorithm can use Bezier curves to describe the contours obtained during vectorization. Bezier curves are mathematical curves defined by a set of control points and used to create smooth curves.

  • Application: Vectorization of contours and objects.
  • Advantages: Allows complex shapes to be described precisely using a few control points.
  • Limitations: The algorithm may require complex computations to optimize curves for complex images.

2.3. Marching Squares Algorithm

This algorithm is used to create vector objects from raster data by analyzing the pixels that form the boundaries of objects. The algorithm starts with a square on a pixel grid and gradually moves across the image, creating contours wherever the pixel color changes.

  • Application: Converting raster images into contours to create vector objects.
  • Advantages: Well suited to images with clear boundaries.
  • Limitations: May not give good results on images with many details or smooth transitions.

2.4. "Flood Fill" Algorithm

The flood-fill algorithm is used to detect closed regions in an image. It looks for pixels sharing a particular color identity and fills them, which can be used for vectorization.

  • Application: Vectorization of simple images with regions of a single color or small variations.
  • Advantages: Simplicity of implementation.
  • Limitations: Not suitable for images with many small details.

3. Contour simplification algorithms

Once the contours or boundaries of an object have been detected and converted into vector lines, it is often necessary to simplify them to improve quality and reduce complexity (the number of points).

3.1. Douglas-Peucker Algorithm

This algorithm is used to simplify polygons and contours by reducing the number of points while minimizing the error between the original and simplified contour.

  • Application: Simplification of complex contours and objects.
  • Advantages: Reduces the number of points while preserving the overall shape.
  • Limitations: May lose detail on complex contours.

3.2. Ramer-Douglas-Peucker Algorithm

This algorithm is a modification of the Douglas-Peucker algorithm and is used to simplify curves represented as polylines. It selects the most significant points and discards less significant ones.

  • Application: Simplification of polylines and contours.
  • Advantages: Fast processing and accurate shape preservation.
  • Limitations: Quality loss on complex contours.

4. Algorithms for color images

More sophisticated methods, which can take into account hue, saturation, and pixel brightness, are used for vectorizing color images.

4.1. K-means clustering

This algorithm is used to cluster pixels by color and then convert these clusters into vector regions. It divides the image into several color groups (classes), which simplifies further vectorization.

  • Application: Vectorization of color images.
  • Advantages: Works well for images with a limited number of colors.
  • Limitations: Requires significant computational resources for complex images.

Conclusion

The process of vectorizing raster images includes several stages, such as contour detection, tracing contours into vector lines, and simplifying these contours to reduce complexity. The choice of algorithm depends on the type of image, the required accuracy, and the complexity of the task. Algorithms such as Potrace, Canny, and the Douglas-Peucker algorithm are among the most popular for obtaining high-quality vector objects.

Automatic vectorization. Manual vectorization.

Automatic vectorization is the process of converting raster (bitmap) images into vector formats with minimal user intervention. This process is carried out using algorithms that identify contours and turn them into mathematical descriptions (lines, curves, polygons, etc.).

The automatic vectorization process

  1. Image preprocessing
    At this stage, filtering is often used to increase contrast or reduce noise in the image. Algorithms may use various image-processing methods, such as:

    • Gaussian blur for smoothing.
    • Binarization (converting the image to black and white) to simplify the task.
  2. Contour detection
    Algorithms such as Canny or Sobel highlight contours in the image. This is a key step, since contours define the boundaries of the objects to be vectorized.

  3. Vectorization of contours
    Once contours have been detected, algorithms are used to convert them into vector lines. This can be done using Bezier curves or other methods, for example, point reduction using the Douglas-Peucker algorithm.

  4. Color segmentation (for color images)
    For color images, a clustering method (such as k-means) is applied to divide the image into regions of similar colors, which helps in vectorizing individual objects.

  5. Simplification and optimization
    After the contours have been vectorized, algorithms such as the Ramer-Douglas-Peucker algorithm are often used to simplify the images, reducing the number of points and smoothing the lines.

Tools for automatic vectorization

  • Adobe Illustrator (Image Trace)
    The Image Trace feature automates the vectorization process in Illustrator, allowing various modes to be selected (for example, black-and-white or color vectorization).

  • CorelDRAW (PowerTRACE)
    Vectorization of raster images using the PowerTRACE feature. In CorelDRAW, raster images can be automatically converted to vector form with settings for precision and complexity.

  • Inkscape
    A free, open-source tool for vectorization using the Trace Bitmap feature. Inkscape allows images to be vectorized with fine-grained precision settings.

  • Vector Magic
    A specialized tool for automatic image vectorization. It uses sophisticated algorithms to convert raster images into high-quality vector images.

  • Potrace
    A free, open-source program for tracing raster images into vector formats such as SVG, EPS, and PDF.

Automatic vectorization is defined as an automated technology for converting raster data into vector objects. This process is controlled by the user, who manages the course of vectorization. Factors such as image resolution, the amount of noise (interference) in the image, and the actual content of the scanned document determine the final vectorization result.

ArcScan supports two vectorization methods: centerline and outline.

Centerline vectorization allows vector objects to be created along the center of linear raster features.

Outline digitizing allows vector objects to be created along the boundary of linear raster features.

Viewing and Converting Graphics Files

The figure below shows centerline tracing used to create linear features. The square points correspond to the nodes of the vector line being created.

Viewing and Converting Graphics Files

With Vectorization Trace, it is enough to simply point the cursor in the direction in which you want to perform vectorization and click the mouse. With each click, objects are created along the axes of the raster cells. The current vectorization settings affect the resulting vector geometry. You have the option to create linear or polygonal objects.

The figure below shows tracing and raster closure used when creating polygonal objects.

Viewing and Converting Graphics Files

Shape recognition

Objects of a particular shape, such as a building or a storage tank, can be vectorized using shape recognition tools. This allows objects to be created with a single mouse click on the raster object you want to select.

The figure shows, in red, automatically selected objects of circular and rectangular shape.

Viewing and Converting Graphics Files

Manual vectorization

Manual vectorization is the process of creating vector images from scratch or based on raster images using drawing tools. This method requires more time and skill but allows for maximum precision and control over the result. Complex images such as logos, illustrations, or intricate graphic elements can be readily handled manually.

The manual vectorization process

  1. Image import
    A vector image is usually created based on a raster image (for example, a scanned drawing or photograph). This image is imported into a vector editor (for example, Illustrator, CorelDRAW, or Inkscape).

  2. Creating contours
    A contour is drawn for each element of the image using tools for drawing lines, curves, or shapes. This process can use:

    • The Pen Tool for drawing Bezier curves.
    • The "Pencil" or "Free Drawing" tool for creating more complex shapes.
  3. Defining colors and fills
    After the contours have been created, colors, gradients, and textures can be added. The color palette can be adjusted manually, and the areas to be filled with particular colors can be precisely defined.

  4. Using layers and objects
    Vector images are often created using layers, making it convenient to work with different parts of the image and create more complex compositions.

  5. Editing and refinement
    Contours can be manually adjusted, errors corrected, and details improved. Manual vectorization gives full control for precisely adjusting each element.

  6. Export and saving
    Once drawing is complete, the vector image is exported to the required format, such as SVG, EPS, or AI.

Tools for manual vectorization

  • Adobe Illustrator
    One of the most popular tools for manual vectorization, with powerful drawing and editing capabilities.

  • CorelDRAW
    An excellent tool for professional vector graphics, with powerful drawing and editing tools.

  • Inkscape
    A free, open-source alternative to Illustrator, which also supports manual vectorization using drawing tools.

  • Affinity Designer
    A paid but relatively affordable vector graphics tool with a convenient interface for drawing and creating illustrations.

Advantages and limitations

Automatic vectorization:

  • Advantages: Fast conversion, especially for simple images such as logos or diagrams.
  • Limitations: May not produce ideal results for complex images, such as photographs with many small details.

Manual vectorization:

  • Advantages: Full control over the quality and detail of the image, suitable for complex and detailed work.
  • Limitations: Requires significant time and skill in working with vector tools.

Conclusion

Automatic vectorization is ideal for simple, well-defined images such as logos, graphics, and illustrations. It is a fast process that saves time, but its accuracy depends on the quality of the original raster image and the algorithm settings.

Manual vectorization is the best choice when high precision is required or when working with more complex images. This method gives full control over the result and allows unique images to be created, but requires more time and skill.

Depending on the task, the appropriate method can be chosen: automatic for fast conversion or manual for achieving the highest quality.

Comments

To leave a comment

If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

Lectures and tutorial on "computer graphics"

Terms: computer graphics