1. 无损图像的格式有:PNG、GIF、BMP、TIFF 等。

  2. 无损图像的原理是通过去除图像中的冗余信息来减小图像的文件大小,同时保持图像质量不变。这些冗余信息包括图像中的重复像素、相似颜色等。

  3. 图像压缩的比较著名的技巧和算法手段有:哈夫曼编码、LZW 压缩、RLE 压缩、LZ77 压缩、LZ78 压缩、Arithmetic 编码、JPEG2000 等。

  4. 提供无损图像的网站有:Unsplash、Pexels、Pixabay 等。

  5. 可以在 Matlab 中完成的图像压缩实验有:Lempel-Ziv-Welch(LZW)压缩、Run-Length Encoding(RLE)压缩、Huffman 编码压缩等。以下是 Matlab 代码示例:

LZW 压缩:

function [compressed, dictionary] = LZW_Compress(input)

    % Initialize the dictionary
    dictionary = cell(256, 1);
    for i = 1:256
        dictionary{i} = uint8(i-1);
    end

    % Compress the input
    compressed = [];
    i = 1;
    while i <= length(input)

        % Find the longest string in the dictionary that matches the input
        j = i+1;
        while j <= length(input) && any(ismember(dictionary, input(i:j)))
            j = j+1;
        end
        j = j-1;

        % Encode the string
        string = input(i:j);
        index = find(ismember(dictionary, string), 1);
        compressed = [compressed, index-1];

        % Add the new string to the dictionary
        if j < length(input)
            dictionary{end+1} = [string, input(j+1)];
        end

        % Move to the next position
        i = j+1;
    end
end

RLE 压缩:

function [compressed] = RLE_Compress(input)

    % Initialize the compressed output
    compressed = [];

    % Compress the input
    i = 1;
    while i <= length(input)

        % Find the longest run of identical values
        j = i+1;
        while j <= length(input) && input(j) == input(i)
            j = j+1;
        end
        j = j-1;

        % Encode the run
        run_length = j-i+1;
        compressed = [compressed, run_length, input(i)];

        % Move to the next position
        i = j+1;
    end
end

Huffman 编码压缩:

function [compressed, dictionary] = Huffman_Compress(input)

    % Compute the frequency of each symbol in the input
    freq = zeros(256, 1);
    for i = 1:length(input)
        freq(input(i)+1) = freq(input(i)+1) + 1;
    end

    % Generate the Huffman codebook
    dictionary = huffmandict(0:255, freq);

    % Compress the input
    compressed = huffmanenco(input, dictionary);
end

原文地址: https://www.cveoy.top/t/topic/oAt0 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录