Image Compression Using wavelet- MATLAB












2















I am working on image compression based on wavelet in MATLAB... I have constructed the below code. Everything is working fine but the compressed image is displayed as plain black and white image. If I give the decomposition level as 1, it shows compressed image as full black, for the decomposition level: 2, it gives fully white image.. For the decomposition level 3, it gives 3/4 white and 1/4 black color.. Please help. The code I have used is



clear all;

close all;

input_image1=imread('C:UsersPremDocumentsMATLABmandrill.jpg');

input_image=imnoise(input_image1,'speckle',.01);

figure;

imshow(input_image);

n=input('enter the decomposition level=');

[Lo_D,Hi_D,Lo_R,Hi_R] = wfilters('haar');

[c,s]=wavedec2(input_image,n,Lo_D,Hi_D);

disp(' the decomposition vector Output is');

disp(c);

[thr,nkeep] = wdcbm2(c,s,1.5,3*prod(s(1,:)));

[compressed_image,TREED,comp_ratio,PERFL2] =wpdencmp(thr,'s',n,'haar','threshold',5,1);

disp('compression ratio in percentage');

disp(comp_ratio);

re_ima1 = waverec2(c,s,'haar');

re_ima=uint8(re_ima1);

subplot(1,3,1);

imshow(input_image);

title('i/p image');

subplot(1,3,2);

imshow(compressed_image);

title('compressed image');

subplot(1,3,3);

imshow(re_ima);

title('reconstructed image');









share|improve this question





























    2















    I am working on image compression based on wavelet in MATLAB... I have constructed the below code. Everything is working fine but the compressed image is displayed as plain black and white image. If I give the decomposition level as 1, it shows compressed image as full black, for the decomposition level: 2, it gives fully white image.. For the decomposition level 3, it gives 3/4 white and 1/4 black color.. Please help. The code I have used is



    clear all;

    close all;

    input_image1=imread('C:UsersPremDocumentsMATLABmandrill.jpg');

    input_image=imnoise(input_image1,'speckle',.01);

    figure;

    imshow(input_image);

    n=input('enter the decomposition level=');

    [Lo_D,Hi_D,Lo_R,Hi_R] = wfilters('haar');

    [c,s]=wavedec2(input_image,n,Lo_D,Hi_D);

    disp(' the decomposition vector Output is');

    disp(c);

    [thr,nkeep] = wdcbm2(c,s,1.5,3*prod(s(1,:)));

    [compressed_image,TREED,comp_ratio,PERFL2] =wpdencmp(thr,'s',n,'haar','threshold',5,1);

    disp('compression ratio in percentage');

    disp(comp_ratio);

    re_ima1 = waverec2(c,s,'haar');

    re_ima=uint8(re_ima1);

    subplot(1,3,1);

    imshow(input_image);

    title('i/p image');

    subplot(1,3,2);

    imshow(compressed_image);

    title('compressed image');

    subplot(1,3,3);

    imshow(re_ima);

    title('reconstructed image');









    share|improve this question



























      2












      2








      2


      1






      I am working on image compression based on wavelet in MATLAB... I have constructed the below code. Everything is working fine but the compressed image is displayed as plain black and white image. If I give the decomposition level as 1, it shows compressed image as full black, for the decomposition level: 2, it gives fully white image.. For the decomposition level 3, it gives 3/4 white and 1/4 black color.. Please help. The code I have used is



      clear all;

      close all;

      input_image1=imread('C:UsersPremDocumentsMATLABmandrill.jpg');

      input_image=imnoise(input_image1,'speckle',.01);

      figure;

      imshow(input_image);

      n=input('enter the decomposition level=');

      [Lo_D,Hi_D,Lo_R,Hi_R] = wfilters('haar');

      [c,s]=wavedec2(input_image,n,Lo_D,Hi_D);

      disp(' the decomposition vector Output is');

      disp(c);

      [thr,nkeep] = wdcbm2(c,s,1.5,3*prod(s(1,:)));

      [compressed_image,TREED,comp_ratio,PERFL2] =wpdencmp(thr,'s',n,'haar','threshold',5,1);

      disp('compression ratio in percentage');

      disp(comp_ratio);

      re_ima1 = waverec2(c,s,'haar');

      re_ima=uint8(re_ima1);

      subplot(1,3,1);

      imshow(input_image);

      title('i/p image');

      subplot(1,3,2);

      imshow(compressed_image);

      title('compressed image');

      subplot(1,3,3);

      imshow(re_ima);

      title('reconstructed image');









      share|improve this question
















      I am working on image compression based on wavelet in MATLAB... I have constructed the below code. Everything is working fine but the compressed image is displayed as plain black and white image. If I give the decomposition level as 1, it shows compressed image as full black, for the decomposition level: 2, it gives fully white image.. For the decomposition level 3, it gives 3/4 white and 1/4 black color.. Please help. The code I have used is



      clear all;

      close all;

      input_image1=imread('C:UsersPremDocumentsMATLABmandrill.jpg');

      input_image=imnoise(input_image1,'speckle',.01);

      figure;

      imshow(input_image);

      n=input('enter the decomposition level=');

      [Lo_D,Hi_D,Lo_R,Hi_R] = wfilters('haar');

      [c,s]=wavedec2(input_image,n,Lo_D,Hi_D);

      disp(' the decomposition vector Output is');

      disp(c);

      [thr,nkeep] = wdcbm2(c,s,1.5,3*prod(s(1,:)));

      [compressed_image,TREED,comp_ratio,PERFL2] =wpdencmp(thr,'s',n,'haar','threshold',5,1);

      disp('compression ratio in percentage');

      disp(comp_ratio);

      re_ima1 = waverec2(c,s,'haar');

      re_ima=uint8(re_ima1);

      subplot(1,3,1);

      imshow(input_image);

      title('i/p image');

      subplot(1,3,2);

      imshow(compressed_image);

      title('compressed image');

      subplot(1,3,3);

      imshow(re_ima);

      title('reconstructed image');






      matlab wavelet






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 25 '13 at 14:59









      Oliver Charlesworth

      228k25466598




      228k25466598










      asked Jan 25 '13 at 14:57









      user101509user101509

      29110




      29110
























          2 Answers
          2






          active

          oldest

          votes


















          0














          My opinion the problem with scaling the images .You can divide resulted images by suitable number or use



          imagesc(desire image);

          subplot(1,3,2);

          imshow(compressed_image/156);

          title('compressed image');

          subplot(1,3,3);

          imagesc(re_ima);

          title('reconstructed image');





          share|improve this answer

































            -1














            On this line



             [compressed_image,TREED,comp_ratio,PERFL2] =wpdencmp(thr,'s',n,'haar','threshold',5,1);


            You are passing a theshold as a signal ... that is not correct.






            share|improve this answer
























            • then how to do it?

              – user101509
              Jan 26 '13 at 16:05











            • @user101509 Try [compressed_image,TREED,comp_ratio,PERFL2] =wpdencmp(input_image,'s',n,'haar','threshold',5,1); - I don't currently have access to the wavelet toolbox and I can't remember exactly what this function does with its inputs. help wpdencmp for more information on input arguments

              – user1207217
              Jan 26 '13 at 17:52











            • It didn't work... now the compressed image is fully white for all 3 levels

              – user101509
              Jan 27 '13 at 11:00











            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f14524368%2fimage-compression-using-wavelet-matlab%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            My opinion the problem with scaling the images .You can divide resulted images by suitable number or use



            imagesc(desire image);

            subplot(1,3,2);

            imshow(compressed_image/156);

            title('compressed image');

            subplot(1,3,3);

            imagesc(re_ima);

            title('reconstructed image');





            share|improve this answer






























              0














              My opinion the problem with scaling the images .You can divide resulted images by suitable number or use



              imagesc(desire image);

              subplot(1,3,2);

              imshow(compressed_image/156);

              title('compressed image');

              subplot(1,3,3);

              imagesc(re_ima);

              title('reconstructed image');





              share|improve this answer




























                0












                0








                0







                My opinion the problem with scaling the images .You can divide resulted images by suitable number or use



                imagesc(desire image);

                subplot(1,3,2);

                imshow(compressed_image/156);

                title('compressed image');

                subplot(1,3,3);

                imagesc(re_ima);

                title('reconstructed image');





                share|improve this answer















                My opinion the problem with scaling the images .You can divide resulted images by suitable number or use



                imagesc(desire image);

                subplot(1,3,2);

                imshow(compressed_image/156);

                title('compressed image');

                subplot(1,3,3);

                imagesc(re_ima);

                title('reconstructed image');






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited May 11 '16 at 12:22









                lrnzcig

                2,61442236




                2,61442236










                answered May 11 '16 at 10:45









                MussaMussa

                1




                1

























                    -1














                    On this line



                     [compressed_image,TREED,comp_ratio,PERFL2] =wpdencmp(thr,'s',n,'haar','threshold',5,1);


                    You are passing a theshold as a signal ... that is not correct.






                    share|improve this answer
























                    • then how to do it?

                      – user101509
                      Jan 26 '13 at 16:05











                    • @user101509 Try [compressed_image,TREED,comp_ratio,PERFL2] =wpdencmp(input_image,'s',n,'haar','threshold',5,1); - I don't currently have access to the wavelet toolbox and I can't remember exactly what this function does with its inputs. help wpdencmp for more information on input arguments

                      – user1207217
                      Jan 26 '13 at 17:52











                    • It didn't work... now the compressed image is fully white for all 3 levels

                      – user101509
                      Jan 27 '13 at 11:00
















                    -1














                    On this line



                     [compressed_image,TREED,comp_ratio,PERFL2] =wpdencmp(thr,'s',n,'haar','threshold',5,1);


                    You are passing a theshold as a signal ... that is not correct.






                    share|improve this answer
























                    • then how to do it?

                      – user101509
                      Jan 26 '13 at 16:05











                    • @user101509 Try [compressed_image,TREED,comp_ratio,PERFL2] =wpdencmp(input_image,'s',n,'haar','threshold',5,1); - I don't currently have access to the wavelet toolbox and I can't remember exactly what this function does with its inputs. help wpdencmp for more information on input arguments

                      – user1207217
                      Jan 26 '13 at 17:52











                    • It didn't work... now the compressed image is fully white for all 3 levels

                      – user101509
                      Jan 27 '13 at 11:00














                    -1












                    -1








                    -1







                    On this line



                     [compressed_image,TREED,comp_ratio,PERFL2] =wpdencmp(thr,'s',n,'haar','threshold',5,1);


                    You are passing a theshold as a signal ... that is not correct.






                    share|improve this answer













                    On this line



                     [compressed_image,TREED,comp_ratio,PERFL2] =wpdencmp(thr,'s',n,'haar','threshold',5,1);


                    You are passing a theshold as a signal ... that is not correct.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Jan 25 '13 at 15:07









                    user1207217user1207217

                    4521315




                    4521315













                    • then how to do it?

                      – user101509
                      Jan 26 '13 at 16:05











                    • @user101509 Try [compressed_image,TREED,comp_ratio,PERFL2] =wpdencmp(input_image,'s',n,'haar','threshold',5,1); - I don't currently have access to the wavelet toolbox and I can't remember exactly what this function does with its inputs. help wpdencmp for more information on input arguments

                      – user1207217
                      Jan 26 '13 at 17:52











                    • It didn't work... now the compressed image is fully white for all 3 levels

                      – user101509
                      Jan 27 '13 at 11:00



















                    • then how to do it?

                      – user101509
                      Jan 26 '13 at 16:05











                    • @user101509 Try [compressed_image,TREED,comp_ratio,PERFL2] =wpdencmp(input_image,'s',n,'haar','threshold',5,1); - I don't currently have access to the wavelet toolbox and I can't remember exactly what this function does with its inputs. help wpdencmp for more information on input arguments

                      – user1207217
                      Jan 26 '13 at 17:52











                    • It didn't work... now the compressed image is fully white for all 3 levels

                      – user101509
                      Jan 27 '13 at 11:00

















                    then how to do it?

                    – user101509
                    Jan 26 '13 at 16:05





                    then how to do it?

                    – user101509
                    Jan 26 '13 at 16:05













                    @user101509 Try [compressed_image,TREED,comp_ratio,PERFL2] =wpdencmp(input_image,'s',n,'haar','threshold',5,1); - I don't currently have access to the wavelet toolbox and I can't remember exactly what this function does with its inputs. help wpdencmp for more information on input arguments

                    – user1207217
                    Jan 26 '13 at 17:52





                    @user101509 Try [compressed_image,TREED,comp_ratio,PERFL2] =wpdencmp(input_image,'s',n,'haar','threshold',5,1); - I don't currently have access to the wavelet toolbox and I can't remember exactly what this function does with its inputs. help wpdencmp for more information on input arguments

                    – user1207217
                    Jan 26 '13 at 17:52













                    It didn't work... now the compressed image is fully white for all 3 levels

                    – user101509
                    Jan 27 '13 at 11:00





                    It didn't work... now the compressed image is fully white for all 3 levels

                    – user101509
                    Jan 27 '13 at 11:00


















                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f14524368%2fimage-compression-using-wavelet-matlab%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Wiesbaden

                    Marschland

                    Dieringhausen