Question How to implement huffman algorithm for image

calculus67

Member
Joined
Oct 31, 2016
Messages
9
Programming Experience
1-3
I coded a visual c# program using huffman for txt files.I can easily compress all txt files.But ı want to compress image.My program take a txt files and compress then output format is .huf also ı can deceompress it.But how can ı do it for image ?
 
You can read the image into a byte array and convert that to a base64 string. Then it's just text like any other, so you can use the method you already have to encode it.
 
how to convert may you give an example.
What do you not understand about the examples you found when you searched the web?
For image compressing can ı need to change my all codes ?
If you had to change everything then I wouldn't have said this:
Then it's just text like any other, so you can use the method you already have to encode it.
If you have a method that takes an unencoded string as an argument and returns an encoded string then it doesn't matter where the unencoded string comes from. It could be the contents of a text file or it could be the result of passing a byte array to Convert.ToBase64String. A String is a String, regardless of its source.
 
What do you not understand about the examples you found when you searched the web?

If you had to change everything then I wouldn't have said this:If you have a method that takes an unencoded string as an argument and returns an encoded string then it doesn't matter where the unencoded string comes from. It could be the contents of a text file or it could be the result of passing a byte array to Convert.ToBase64String. A String is a String, regardless of its source.

My program take txt files and read all characters.Program doesnt encoded character.Program encoded characher's Ascii code.Sorry I am not very good in c#.I need someone show how to do it.I hope you may help me.My program's link is above.Thank you.

https://drive.google.com/open?id=0BzqvTb8NFK0OT1k3SVowR1Q0QU0
 
Program doesnt encoded character.Program encoded characher's Ascii code.

It doesn't matter. You're still starting with text. It doesn't matter whether that text comes from a text file or the result of converting a byte array to a base64 string. Text is text.

I'm not here to write your code for you. We're none of us very good at programming when we start but we get better by doing it. I've told you what to do. Now it's time for you to do it. You can't succeed if you don't. If you try and it doesn't work then I will help you fix the issues but I'm not going just do it for you so that you don't have to try.
 
It doesn't matter. You're still starting with text. It doesn't matter whether that text comes from a text file or the result of converting a byte array to a base64 string. Text is text.

I'm not here to write your code for you. We're none of us very good at programming when we start but we get better by doing it. I've told you what to do. Now it's time for you to do it. You can't succeed if you don't. If you try and it doesn't work then I will help you fix the issues but I'm not going just do it for you so that you don't have to try.

I must do like that given the link ?.An image file convert to base 64 then program take base64 strings decode processing is opposite of encode .
https://www.youtube.com/watch?v=P0UJ6ob4I5k
 
I'm not going to be watching any videos. If there's anything I need to know then explain it. What you need to do is write a method that takes an unencoded String and returns encoded data. You can then call that method and pass any string you want, e.g. the contents of a text file or the result of calling Convert.ToBase64String with the a byte array obtained from an image. It requires very little effort to find out how to get a byte array from an image file or an Image object from the web. You've now wasted 24 hours when you should have done that when I first told you that it's what is required. I will not be contributing any further until I see some effort in that direction.
 
I'm not going to be watching any videos. If there's anything I need to know then explain it. What you need to do is write a method that takes an unencoded String and returns encoded data. You can then call that method and pass any string you want, e.g. the contents of a text file or the result of calling Convert.ToBase64String with the a byte array obtained from an image. It requires very little effort to find out how to get a byte array from an image file or an Image object from the web. You've now wasted 24 hours when you should have done that when I first told you that it's what is required. I will not be contributing any further until I see some effort in that direction.


I converted and image to basestring64 but ı have a problem like this.For example an image file is 10 mb after convert with base64 text size is 14 mb this text is compressed by huffman then result is 12 mb.
 
Back
Top Bottom