BEST代写-线上编程学术专家

Best代写-最专业靠谱代写IT | CS | 留学生作业 | 编程代写Java | Python |C/C++ | PHP | Matlab | Assignment Project Homework代写

C语言代写|C Language Image Compression

C语言代写|C Language Image Compression

这是一个加拿大的C语言作业代写,主要与图像压缩相关

1. (8 Marks) Develop the following function and store it in a file named: generate_pixel_frequency.c

long int *generate_pixel_frequency(struct PGM_Image *input_pgm_image, int
*number_of_non_zero_values_in_the_frequency_array)

This function accepts two parameters:

  • input_pgm_image (a pointer to a PGM_Image structure–see pnm_library.tar)
  • number_of_non_zero_values_in_the_frequency_array (a pointer to an integer)

The function:

  • Dynamically allocates a long int array of (max_gray_value + 1) elements,
  • Reads ALL pixels in the provided PGM image and record the frequency of occurrence of each pixel values in
    the allocated array
  • Stores in the *number_of_non_zero_values_in_the_frequency_array the number of non-zero values in the
    frequency array
  • Returns a pointer to the allocated array

2. (10 Marks) Develop the following function and store it in a file named generate_huffman_nodes.c
struct node *generate_huffman_nodes(long int *pixel_frequency, int max_gray_value, int
number_of_non_zero_values_in_the_frequency_array)

This function accepts three parameters:

  • a pointer to a long integer array which contains the frequency of occurrence of each pixel value in an image
  • an integer representing the max_gray_value in the image
  • an integer representing the number of non-zero values in the frequency array

The function should utilize the input data to generate all Huffman nodes in a form of ordered pairs of pixel values,
where a node is declared as: struct node {int first_value; int second_value;};

The number of nodes is less by one than number_of_non_zero_values_in_the_frequency_array. The function will
return a pointer to a node array which contains all Huffman nodes in order (see Huffman lecture for more details).

3. (10 Marks) Develop the following function and store it in a file named huffman_encode_image.c
unsigned char *huffman_encode_image(struct PGM_Image *input_pgm_image, struct node *huffman_node, int
number_of_nodes, long int *length_of_encoded_image_array)

This function accepts four parameters:

  • input_pgm_image, a pointer to a PGM_Image structure–see pnm_library.tar
  • huffman_node, a pointer to an array of struct node which contains all Huffman nodes.
  • number_of_nodes, an integer representing the number of nodes stored in *huffman_node
  • length_of_encoded_image_array, a pointer to a long integer which will indicate the exact length of the
    Huffman encoded image array in bytes

The function should

  • generate a Huffman code for each pixel value in the provided image
  • use the generated Huffman codes to Huffman encode the provided image
  • return a pointer to an unsigned character array which will contain the Huffman encoded image after encoding it
bestdaixie

评论已关闭。