Beamer Highlighting some part of an image and hiding remaining part

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
16
down vote

favorite
7












I want to highlight some part of an image and hiding the remaining part. My minimum working example is below. Any help will be highly appreciated. Thanks



enter image description here



documentclassbeamer
usepackage[T1]fontenc
usepackagetikz

begindocument

beginframe

begintikzpicture
node[anchor = south west, inner sep = 0] (A) at (0, 0) includegraphics[width = 0.8paperwidth, height = 10cm, keepaspectratio]Effile.jpeg;

draw[red, ultra thick] (1.05, 5.1) rectangle (2.49, 4.3);

fill [draw = none, fill = white, fill opacity = 1.0] (1.05, 5.1) -- (2.49, 5.1) -- (2.49, 1.05) -- cycle;

endtikzpicture

endframe

enddocument






share|improve this question
























    up vote
    16
    down vote

    favorite
    7












    I want to highlight some part of an image and hiding the remaining part. My minimum working example is below. Any help will be highly appreciated. Thanks



    enter image description here



    documentclassbeamer
    usepackage[T1]fontenc
    usepackagetikz

    begindocument

    beginframe

    begintikzpicture
    node[anchor = south west, inner sep = 0] (A) at (0, 0) includegraphics[width = 0.8paperwidth, height = 10cm, keepaspectratio]Effile.jpeg;

    draw[red, ultra thick] (1.05, 5.1) rectangle (2.49, 4.3);

    fill [draw = none, fill = white, fill opacity = 1.0] (1.05, 5.1) -- (2.49, 5.1) -- (2.49, 1.05) -- cycle;

    endtikzpicture

    endframe

    enddocument






    share|improve this question






















      up vote
      16
      down vote

      favorite
      7









      up vote
      16
      down vote

      favorite
      7






      7





      I want to highlight some part of an image and hiding the remaining part. My minimum working example is below. Any help will be highly appreciated. Thanks



      enter image description here



      documentclassbeamer
      usepackage[T1]fontenc
      usepackagetikz

      begindocument

      beginframe

      begintikzpicture
      node[anchor = south west, inner sep = 0] (A) at (0, 0) includegraphics[width = 0.8paperwidth, height = 10cm, keepaspectratio]Effile.jpeg;

      draw[red, ultra thick] (1.05, 5.1) rectangle (2.49, 4.3);

      fill [draw = none, fill = white, fill opacity = 1.0] (1.05, 5.1) -- (2.49, 5.1) -- (2.49, 1.05) -- cycle;

      endtikzpicture

      endframe

      enddocument






      share|improve this question












      I want to highlight some part of an image and hiding the remaining part. My minimum working example is below. Any help will be highly appreciated. Thanks



      enter image description here



      documentclassbeamer
      usepackage[T1]fontenc
      usepackagetikz

      begindocument

      beginframe

      begintikzpicture
      node[anchor = south west, inner sep = 0] (A) at (0, 0) includegraphics[width = 0.8paperwidth, height = 10cm, keepaspectratio]Effile.jpeg;

      draw[red, ultra thick] (1.05, 5.1) rectangle (2.49, 4.3);

      fill [draw = none, fill = white, fill opacity = 1.0] (1.05, 5.1) -- (2.49, 5.1) -- (2.49, 1.05) -- cycle;

      endtikzpicture

      endframe

      enddocument








      share|improve this question











      share|improve this question




      share|improve this question










      asked Aug 13 at 8:35









      MYaseen208

      2,93694393




      2,93694393




















          3 Answers
          3






          active

          oldest

          votes

















          up vote
          19
          down vote



          accepted










          Edit
          With the overlay-beamer-styles library this can be done quite elegantly.
          Apparently one does not need the overlay-beamer-styles library, because the Tikz macros work with the overlay syntax of beamer!



          I include the image in the same way, but name the node image. Also, it doesn't matter where the node is placed.



          begintikzpicture
          node[anchor = south west, inner sep = 0] (image) includegraphics[width = 0.8paperwidth, height = 10cm, keepaspectratio] Effile.jpeg;


          Then I can define a scope that has (0,0) in the bottom left corner of image, (1,0) in the bottom right corner, (0,1) in the top left corner and (1,1) in the top right corner.



           beginscope[shift=(image.south west),x=(image.south east),y=(image.north west)]


          Drawing a grid that scales with the image is now straightforward. This makes it easy to recognize the place of the paths needed in the next step.



           % Draw a overlaying grid to easily see where the rectangles must be, this can be commented out in the final version
          draw foreach xy in 0,0.1,...,1.001
          (xy,0) -- node[pos=0,below]pgfmathprintnumberxy (xy,1)
          (0,xy) -- node[pos=0,left]pgfmathprintnumberxy (1,xy);


          Having identified the paths of the segment I want to highlight, I can add these to my foreach loop, which draws a big white rectangle on top of the image, excludes the path I specified, and draws an additional red rectangle around the highlighted segment. Additionally, the overlay-beamer-styles library provides the visible on=<> key, which can be used with the counter in the foreach.



           foreach[count=i] mypath in 
          (0.1,0.55) rectangle (0.25,0.65),
          (0.45,0.85) rectangle (0.6,0.95),
          (0.5,0.5) circle (1cm),
          (0.75,0.3) rectangle (0.85,0.35) (0.25,0.75) circle (1.5cm)

          filldraw<i>[white,opacity=0.75,even odd rule] (0,0) rectangle (1,1) mypath;
          draw<i>[red,ultra thick] mypath;



          Finally close the scope and the tikzpicture.



           endscope
          endtikzpicture


          This results in:



          enter image description here



          where the grid is still visible, and the white rectangle is 'see-through', but for a final version this can be made opaque and the grid can be hidden.



          enter image description here



          Total MWE (also note that I draw the grid on top of the images and white rectangle, because otherwise it would not be very helpful):



          documentclassbeamer
          usepackage[T1]fontenc
          usepackagetikz

          begindocument
          beginframe
          begintikzpicture
          node[anchor = south west, inner sep = 0] (image) includegraphics[width = 0.8paperwidth, height = 10cm, keepaspectratio] Effile.jpeg;

          beginscope[shift=(image.south west),x=(image.south east),y=(image.north west)]

          foreach[count=i] mypath in
          (0.1,0.55) rectangle (0.25,0.65),
          (0.45,0.85) rectangle (0.6,0.95),
          (0.5,0.5) circle (1cm),
          (0.75,0.3) rectangle (0.85,0.35) (0.25,0.75) circle (1.5cm)

          filldraw<i>[white,even odd rule] (0,0) rectangle (1,1) mypath;
          draw<i>[red,ultra thick] mypath;


          % Draw a overlaying grid to easily see where the rectangles must be, this can be commented out in the final version
          % draw foreach xy in 0,0.1,...,1.001
          % (xy,0) -- node[pos=0,below]pgfmathprintnumberxy (xy,1)
          % (0,xy) -- node[pos=0,left]pgfmathprintnumberxy (1,xy);
          endscope

          endtikzpicture
          endframe
          enddocument


          Edit 2

          Due to the fancy example shown by @marmot in his answer, I had to add something fancy myself :)



          enter image description here



          This can be done with:



          documentclassbeamer
          usepackage[T1]fontenc
          usepackagetikz

          begindocument
          beginframe
          begintikzpicture
          node[anchor = south west, inner sep = 0] (image) includegraphics[width = 0.8paperwidth, height = 10cm, keepaspectratio] Effile.jpeg;

          beginscope[shift=(image.south west),x=(image.south east),y=(image.north west)]
          clip (0,0) rectangle (1,1);
          foreach[count=i] myDim in 0,5,...,106
          beginscope[shift=(0.5,0.5)]
          filldraw<i>[white,opacity=1,even odd rule,] (-0.5,-0.5) rectangle (0.5,0.5) (0,1.38*myDim mm)
          -- ++(288:myDim mm) -- ++( 0:myDim mm)
          -- ++(216:myDim mm) -- ++(288:myDim mm)
          -- ++(144:myDim mm) -- ++(216:myDim mm)
          -- ++( 72:myDim mm) -- ++(144:myDim mm)
          -- ++( 0:myDim mm) -- cycle;
          draw<i>[red,ultra thick] (0,1.38*myDim mm)
          -- ++(288:myDim mm) -- ++( 0:myDim mm)
          -- ++(216:myDim mm) -- ++(288:myDim mm)
          -- ++(144:myDim mm) -- ++(216:myDim mm)
          -- ++( 72:myDim mm) -- ++(144:myDim mm)
          -- ++( 0:myDim mm) -- cycle;
          endscope

          endscope

          endtikzpicture
          endframe
          enddocument


          Edit 3

          This will (probably (maybe)) be the last one:



          enter image description here



          Done with:



          documentclassbeamer
          usepackage[T1]fontenc
          usepackagetikz

          usetikzlibraryshapes

          begindocument
          beginframe
          begintikzpicture
          node[anchor = south west, inner sep = 0,outer sep=0.5pgflinewidth] (image) includegraphics[width = 0.8paperwidth, height = 10cm, keepaspectratio] Effile.jpeg;

          clip (image.south west) rectangle (image.north east);

          foreach[count=k] myDim in 0,0.2,...,3.4
          ifnumk>1
          defmypath
          [scale=myDim^2] (image.center)
          foreach myPhi [count=i,evaluate=i as j using 0.5*mod(i,2)+0.5] in 0,36,...,359
          ifnumi=1
          +(90+50*sqrt(k)+myPhi:j)
          else
          -- +(90+50*sqrt(k)+myPhi:j)
          fi
          -- cycle

          else
          defmypath
          fi

          filldraw<k>[white]
          (image.south west) rectangle (image.north east) mypath;
          draw<k>[red,ultra thick] mypath;


          endtikzpicture
          endframe
          enddocument


          Edit 4

          This really is the final one:



          enter image description here



          Done with the clip command (sneakingly stolen from @marmot's answer). Also I defined a use node cs style which takes a node name as argument and makes it easier to draw in that relative coordinate system:



          documentclassbeamer
          usepackage[T1]fontenc
          usepackagetikz

          usetikzlibrarycalc

          tikzset
          use node cs/.style=shift=(#1.south west),x=(#1.south east),y=(#1.north west)


          begindocument
          beginframe
          begintikzpicture
          node[anchor = south west, inner sep = 0,opacity=0] (image) includegraphics[width = 0.8paperwidth, height = 10cm, keepaspectratio] Effile.jpeg;

          clip (image.south west) rectangle (image.north east);

          foreach myDim [count=i] in0,...,30
          clip<i>[use node cs=image] let
          n1=max(myDim,0),
          n2=max(myDim - 1,0),
          n3=max(myDim - 2,0),
          n4=max(myDim - 3,0),
          n5=max(myDim - 4,0)
          in
          (0.1,0.2) circle (n1 mm)
          (0.6,0.4) circle (n2 mm)
          (0.8,0.2) circle (n5 mm)
          (0.5,0.3) circle (n1 mm)
          (0.1,0.8) circle (n5 mm)
          (0.4,0.9) circle (n3 mm)
          (0.7,0.7) circle (n1 mm)
          (0.2,0.5) circle (n3 mm)
          (0.9,0.6) circle (n2 mm)
          (0.9,0.8) circle (n1 mm);

          node[anchor = south west, inner sep = 0] includegraphics[width = 0.8paperwidth, height = 10cm, keepaspectratio] Effile.jpeg;

          endtikzpicture
          endframe
          enddocument





          share|improve this answer





























            up vote
            12
            down vote













            I think Max gave you already a perfect answer. This here is just for fun and to show a slightly different approach using clip. You could just clip the desired regions using only.



            documentclassbeamer
            usepackagetikz

            begindocument

            beginframe

            begintikzpicture
            coordinate (O) at (0,0);
            node[anchor = south west, inner sep = 0,opacity=0] (A) at (O) includegraphics[width = 0.8paperwidth, height = 10cm, keepaspectratio]Effile.jpeg;
            only<1>clip (A.center) circle (1cm);
            only<2>clip (A.center) circle (2cm);
            only<3>clip (1.05, 5.1) rectangle (2.49, 4.3);
            only<4>
            node[anchor = south west, inner sep = 0] at (O) includegraphics[width = 0.8paperwidth, height = 10cm, keepaspectratio]Effile.jpeg;
            only<3>draw[red, ultra thick] (1.05, 5.1) rectangle (2.49, 4.3);
            endtikzpicture
            endframe
            enddocument


            enter image description here



            And one can of course get rid of only and do other things like this.



            documentclassbeamer
            usepackagetikz

            begindocument

            beginframe

            begintikzpicture
            coordinate (O) at (0,0);
            node[anchor = south west, inner sep = 0,opacity=0] (A) at (O) includegraphics[width = 0.8paperwidth, height = 10cm, keepaspectratio]Effile.jpeg;
            foreach X [count=Y] in 0.9,0.8,...,0.1

            path (A.south west) -- (A.north east) coordinate[pos=X*0.5] (BL)
            coordinate[pos=1-0.5*X] (TR);
            clip<Y> (BL) rectangle (TR);

            node[anchor = south west, inner sep = 0] at (O) includegraphics[width = 0.8paperwidth, height = 10cm, keepaspectratio]Effile.jpeg;
            endtikzpicture
            endframe
            enddocument


            enter image description here



            EDIT: I hadn't seen Max' super nice updates. So I had to rewrite his nice star code in a somewhat shorter way. One can load shapes.geometric, which also has a star (and many other shapes), and use path picture to clip the pic against that shape. ;-)



            documentclassbeamer
            usepackagetikz
            usetikzlibraryshapes.geometric
            begindocument
            beginframe
            begintikzpicture
            path[use as bounding box] (-6,-4) rectangle (6,4);
            foreach X [count=Y]in 2,2.4,...,16
            node<Y> [rotate=X*60,star, star point height=0.25*X cm, minimum size=X cm, draw,
            path picture=
            nodeincludegraphics[width = 0.8paperwidth, height = 10cm,
            keepaspectratio] Effile.jpeg;]
            (image) ;
            endtikzpicture
            endframe
            enddocument


            enter image description here






            share|improve this answer





























              up vote
              4
              down vote













              May be this could help. By properly naming the node you can use a fill=<color> with fill opacity=<num>. By naming the node we can easily access the coordinates of the vertices, thereby, we can flow-through the region we want:



              documentclassbeamer
              usepackage[T1]fontenc
              usepackagetikz

              begindocument

              beginframe
              % yes this is the original pic just for comparing
              begintikzpicture
              node[anchor = south west, inner sep = 0] (A) at (0, 0) includegraphics[width = 0.2paperwidth, height = 10cm, keepaspectratio]example-image-a;

              endtikzpicture
              % the actual stuff, the highlighted picture!
              begintikzpicture
              node[anchor = south west, inner sep = 0] (A) at (0, 0) includegraphics[width = 0.2paperwidth, height = 10cm, keepaspectratio]example-image-a;

              draw[red,ultra thick] (0,0) rectangle (0.5,0.5);
              fill [draw=none, fill=white, fill opacity=1]
              (0,0.5) --
              (A.north west) -- (A.north east) -- (A.south east) --
              (0.5,0) -- (0.5,0.5) -- cycle;

              endtikzpicture

              endframe

              enddocument


              which gives you:



              enter image description here






              share|improve this answer






















                Your Answer







                StackExchange.ready(function()
                var channelOptions =
                tags: "".split(" "),
                id: "85"
                ;
                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',
                convertImagesToLinks: false,
                noModals: false,
                showLowRepImageUploadWarning: true,
                reputationToPostImages: null,
                bindNavPrevention: true,
                postfix: "",
                onDemand: true,
                discardSelector: ".discard-answer"
                ,immediatelyShowMarkdownHelp:true
                );



                );








                 

                draft saved


                draft discarded


















                StackExchange.ready(
                function ()
                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f445840%2fbeamer-highlighting-some-part-of-an-image-and-hiding-remaining-part%23new-answer', 'question_page');

                );

                Post as a guest






























                3 Answers
                3






                active

                oldest

                votes








                3 Answers
                3






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes








                up vote
                19
                down vote



                accepted










                Edit
                With the overlay-beamer-styles library this can be done quite elegantly.
                Apparently one does not need the overlay-beamer-styles library, because the Tikz macros work with the overlay syntax of beamer!



                I include the image in the same way, but name the node image. Also, it doesn't matter where the node is placed.



                begintikzpicture
                node[anchor = south west, inner sep = 0] (image) includegraphics[width = 0.8paperwidth, height = 10cm, keepaspectratio] Effile.jpeg;


                Then I can define a scope that has (0,0) in the bottom left corner of image, (1,0) in the bottom right corner, (0,1) in the top left corner and (1,1) in the top right corner.



                 beginscope[shift=(image.south west),x=(image.south east),y=(image.north west)]


                Drawing a grid that scales with the image is now straightforward. This makes it easy to recognize the place of the paths needed in the next step.



                 % Draw a overlaying grid to easily see where the rectangles must be, this can be commented out in the final version
                draw foreach xy in 0,0.1,...,1.001
                (xy,0) -- node[pos=0,below]pgfmathprintnumberxy (xy,1)
                (0,xy) -- node[pos=0,left]pgfmathprintnumberxy (1,xy);


                Having identified the paths of the segment I want to highlight, I can add these to my foreach loop, which draws a big white rectangle on top of the image, excludes the path I specified, and draws an additional red rectangle around the highlighted segment. Additionally, the overlay-beamer-styles library provides the visible on=<> key, which can be used with the counter in the foreach.



                 foreach[count=i] mypath in 
                (0.1,0.55) rectangle (0.25,0.65),
                (0.45,0.85) rectangle (0.6,0.95),
                (0.5,0.5) circle (1cm),
                (0.75,0.3) rectangle (0.85,0.35) (0.25,0.75) circle (1.5cm)

                filldraw<i>[white,opacity=0.75,even odd rule] (0,0) rectangle (1,1) mypath;
                draw<i>[red,ultra thick] mypath;



                Finally close the scope and the tikzpicture.



                 endscope
                endtikzpicture


                This results in:



                enter image description here



                where the grid is still visible, and the white rectangle is 'see-through', but for a final version this can be made opaque and the grid can be hidden.



                enter image description here



                Total MWE (also note that I draw the grid on top of the images and white rectangle, because otherwise it would not be very helpful):



                documentclassbeamer
                usepackage[T1]fontenc
                usepackagetikz

                begindocument
                beginframe
                begintikzpicture
                node[anchor = south west, inner sep = 0] (image) includegraphics[width = 0.8paperwidth, height = 10cm, keepaspectratio] Effile.jpeg;

                beginscope[shift=(image.south west),x=(image.south east),y=(image.north west)]

                foreach[count=i] mypath in
                (0.1,0.55) rectangle (0.25,0.65),
                (0.45,0.85) rectangle (0.6,0.95),
                (0.5,0.5) circle (1cm),
                (0.75,0.3) rectangle (0.85,0.35) (0.25,0.75) circle (1.5cm)

                filldraw<i>[white,even odd rule] (0,0) rectangle (1,1) mypath;
                draw<i>[red,ultra thick] mypath;


                % Draw a overlaying grid to easily see where the rectangles must be, this can be commented out in the final version
                % draw foreach xy in 0,0.1,...,1.001
                % (xy,0) -- node[pos=0,below]pgfmathprintnumberxy (xy,1)
                % (0,xy) -- node[pos=0,left]pgfmathprintnumberxy (1,xy);
                endscope

                endtikzpicture
                endframe
                enddocument


                Edit 2

                Due to the fancy example shown by @marmot in his answer, I had to add something fancy myself :)



                enter image description here



                This can be done with:



                documentclassbeamer
                usepackage[T1]fontenc
                usepackagetikz

                begindocument
                beginframe
                begintikzpicture
                node[anchor = south west, inner sep = 0] (image) includegraphics[width = 0.8paperwidth, height = 10cm, keepaspectratio] Effile.jpeg;

                beginscope[shift=(image.south west),x=(image.south east),y=(image.north west)]
                clip (0,0) rectangle (1,1);
                foreach[count=i] myDim in 0,5,...,106
                beginscope[shift=(0.5,0.5)]
                filldraw<i>[white,opacity=1,even odd rule,] (-0.5,-0.5) rectangle (0.5,0.5) (0,1.38*myDim mm)
                -- ++(288:myDim mm) -- ++( 0:myDim mm)
                -- ++(216:myDim mm) -- ++(288:myDim mm)
                -- ++(144:myDim mm) -- ++(216:myDim mm)
                -- ++( 72:myDim mm) -- ++(144:myDim mm)
                -- ++( 0:myDim mm) -- cycle;
                draw<i>[red,ultra thick] (0,1.38*myDim mm)
                -- ++(288:myDim mm) -- ++( 0:myDim mm)
                -- ++(216:myDim mm) -- ++(288:myDim mm)
                -- ++(144:myDim mm) -- ++(216:myDim mm)
                -- ++( 72:myDim mm) -- ++(144:myDim mm)
                -- ++( 0:myDim mm) -- cycle;
                endscope

                endscope

                endtikzpicture
                endframe
                enddocument


                Edit 3

                This will (probably (maybe)) be the last one:



                enter image description here



                Done with:



                documentclassbeamer
                usepackage[T1]fontenc
                usepackagetikz

                usetikzlibraryshapes

                begindocument
                beginframe
                begintikzpicture
                node[anchor = south west, inner sep = 0,outer sep=0.5pgflinewidth] (image) includegraphics[width = 0.8paperwidth, height = 10cm, keepaspectratio] Effile.jpeg;

                clip (image.south west) rectangle (image.north east);

                foreach[count=k] myDim in 0,0.2,...,3.4
                ifnumk>1
                defmypath
                [scale=myDim^2] (image.center)
                foreach myPhi [count=i,evaluate=i as j using 0.5*mod(i,2)+0.5] in 0,36,...,359
                ifnumi=1
                +(90+50*sqrt(k)+myPhi:j)
                else
                -- +(90+50*sqrt(k)+myPhi:j)
                fi
                -- cycle

                else
                defmypath
                fi

                filldraw<k>[white]
                (image.south west) rectangle (image.north east) mypath;
                draw<k>[red,ultra thick] mypath;


                endtikzpicture
                endframe
                enddocument


                Edit 4

                This really is the final one:



                enter image description here



                Done with the clip command (sneakingly stolen from @marmot's answer). Also I defined a use node cs style which takes a node name as argument and makes it easier to draw in that relative coordinate system:



                documentclassbeamer
                usepackage[T1]fontenc
                usepackagetikz

                usetikzlibrarycalc

                tikzset
                use node cs/.style=shift=(#1.south west),x=(#1.south east),y=(#1.north west)


                begindocument
                beginframe
                begintikzpicture
                node[anchor = south west, inner sep = 0,opacity=0] (image) includegraphics[width = 0.8paperwidth, height = 10cm, keepaspectratio] Effile.jpeg;

                clip (image.south west) rectangle (image.north east);

                foreach myDim [count=i] in0,...,30
                clip<i>[use node cs=image] let
                n1=max(myDim,0),
                n2=max(myDim - 1,0),
                n3=max(myDim - 2,0),
                n4=max(myDim - 3,0),
                n5=max(myDim - 4,0)
                in
                (0.1,0.2) circle (n1 mm)
                (0.6,0.4) circle (n2 mm)
                (0.8,0.2) circle (n5 mm)
                (0.5,0.3) circle (n1 mm)
                (0.1,0.8) circle (n5 mm)
                (0.4,0.9) circle (n3 mm)
                (0.7,0.7) circle (n1 mm)
                (0.2,0.5) circle (n3 mm)
                (0.9,0.6) circle (n2 mm)
                (0.9,0.8) circle (n1 mm);

                node[anchor = south west, inner sep = 0] includegraphics[width = 0.8paperwidth, height = 10cm, keepaspectratio] Effile.jpeg;

                endtikzpicture
                endframe
                enddocument





                share|improve this answer


























                  up vote
                  19
                  down vote



                  accepted










                  Edit
                  With the overlay-beamer-styles library this can be done quite elegantly.
                  Apparently one does not need the overlay-beamer-styles library, because the Tikz macros work with the overlay syntax of beamer!



                  I include the image in the same way, but name the node image. Also, it doesn't matter where the node is placed.



                  begintikzpicture
                  node[anchor = south west, inner sep = 0] (image) includegraphics[width = 0.8paperwidth, height = 10cm, keepaspectratio] Effile.jpeg;


                  Then I can define a scope that has (0,0) in the bottom left corner of image, (1,0) in the bottom right corner, (0,1) in the top left corner and (1,1) in the top right corner.



                   beginscope[shift=(image.south west),x=(image.south east),y=(image.north west)]


                  Drawing a grid that scales with the image is now straightforward. This makes it easy to recognize the place of the paths needed in the next step.



                   % Draw a overlaying grid to easily see where the rectangles must be, this can be commented out in the final version
                  draw foreach xy in 0,0.1,...,1.001
                  (xy,0) -- node[pos=0,below]pgfmathprintnumberxy (xy,1)
                  (0,xy) -- node[pos=0,left]pgfmathprintnumberxy (1,xy);


                  Having identified the paths of the segment I want to highlight, I can add these to my foreach loop, which draws a big white rectangle on top of the image, excludes the path I specified, and draws an additional red rectangle around the highlighted segment. Additionally, the overlay-beamer-styles library provides the visible on=<> key, which can be used with the counter in the foreach.



                   foreach[count=i] mypath in 
                  (0.1,0.55) rectangle (0.25,0.65),
                  (0.45,0.85) rectangle (0.6,0.95),
                  (0.5,0.5) circle (1cm),
                  (0.75,0.3) rectangle (0.85,0.35) (0.25,0.75) circle (1.5cm)

                  filldraw<i>[white,opacity=0.75,even odd rule] (0,0) rectangle (1,1) mypath;
                  draw<i>[red,ultra thick] mypath;



                  Finally close the scope and the tikzpicture.



                   endscope
                  endtikzpicture


                  This results in:



                  enter image description here



                  where the grid is still visible, and the white rectangle is 'see-through', but for a final version this can be made opaque and the grid can be hidden.



                  enter image description here



                  Total MWE (also note that I draw the grid on top of the images and white rectangle, because otherwise it would not be very helpful):



                  documentclassbeamer
                  usepackage[T1]fontenc
                  usepackagetikz

                  begindocument
                  beginframe
                  begintikzpicture
                  node[anchor = south west, inner sep = 0] (image) includegraphics[width = 0.8paperwidth, height = 10cm, keepaspectratio] Effile.jpeg;

                  beginscope[shift=(image.south west),x=(image.south east),y=(image.north west)]

                  foreach[count=i] mypath in
                  (0.1,0.55) rectangle (0.25,0.65),
                  (0.45,0.85) rectangle (0.6,0.95),
                  (0.5,0.5) circle (1cm),
                  (0.75,0.3) rectangle (0.85,0.35) (0.25,0.75) circle (1.5cm)

                  filldraw<i>[white,even odd rule] (0,0) rectangle (1,1) mypath;
                  draw<i>[red,ultra thick] mypath;


                  % Draw a overlaying grid to easily see where the rectangles must be, this can be commented out in the final version
                  % draw foreach xy in 0,0.1,...,1.001
                  % (xy,0) -- node[pos=0,below]pgfmathprintnumberxy (xy,1)
                  % (0,xy) -- node[pos=0,left]pgfmathprintnumberxy (1,xy);
                  endscope

                  endtikzpicture
                  endframe
                  enddocument


                  Edit 2

                  Due to the fancy example shown by @marmot in his answer, I had to add something fancy myself :)



                  enter image description here



                  This can be done with:



                  documentclassbeamer
                  usepackage[T1]fontenc
                  usepackagetikz

                  begindocument
                  beginframe
                  begintikzpicture
                  node[anchor = south west, inner sep = 0] (image) includegraphics[width = 0.8paperwidth, height = 10cm, keepaspectratio] Effile.jpeg;

                  beginscope[shift=(image.south west),x=(image.south east),y=(image.north west)]
                  clip (0,0) rectangle (1,1);
                  foreach[count=i] myDim in 0,5,...,106
                  beginscope[shift=(0.5,0.5)]
                  filldraw<i>[white,opacity=1,even odd rule,] (-0.5,-0.5) rectangle (0.5,0.5) (0,1.38*myDim mm)
                  -- ++(288:myDim mm) -- ++( 0:myDim mm)
                  -- ++(216:myDim mm) -- ++(288:myDim mm)
                  -- ++(144:myDim mm) -- ++(216:myDim mm)
                  -- ++( 72:myDim mm) -- ++(144:myDim mm)
                  -- ++( 0:myDim mm) -- cycle;
                  draw<i>[red,ultra thick] (0,1.38*myDim mm)
                  -- ++(288:myDim mm) -- ++( 0:myDim mm)
                  -- ++(216:myDim mm) -- ++(288:myDim mm)
                  -- ++(144:myDim mm) -- ++(216:myDim mm)
                  -- ++( 72:myDim mm) -- ++(144:myDim mm)
                  -- ++( 0:myDim mm) -- cycle;
                  endscope

                  endscope

                  endtikzpicture
                  endframe
                  enddocument


                  Edit 3

                  This will (probably (maybe)) be the last one:



                  enter image description here



                  Done with:



                  documentclassbeamer
                  usepackage[T1]fontenc
                  usepackagetikz

                  usetikzlibraryshapes

                  begindocument
                  beginframe
                  begintikzpicture
                  node[anchor = south west, inner sep = 0,outer sep=0.5pgflinewidth] (image) includegraphics[width = 0.8paperwidth, height = 10cm, keepaspectratio] Effile.jpeg;

                  clip (image.south west) rectangle (image.north east);

                  foreach[count=k] myDim in 0,0.2,...,3.4
                  ifnumk>1
                  defmypath
                  [scale=myDim^2] (image.center)
                  foreach myPhi [count=i,evaluate=i as j using 0.5*mod(i,2)+0.5] in 0,36,...,359
                  ifnumi=1
                  +(90+50*sqrt(k)+myPhi:j)
                  else
                  -- +(90+50*sqrt(k)+myPhi:j)
                  fi
                  -- cycle

                  else
                  defmypath
                  fi

                  filldraw<k>[white]
                  (image.south west) rectangle (image.north east) mypath;
                  draw<k>[red,ultra thick] mypath;


                  endtikzpicture
                  endframe
                  enddocument


                  Edit 4

                  This really is the final one:



                  enter image description here



                  Done with the clip command (sneakingly stolen from @marmot's answer). Also I defined a use node cs style which takes a node name as argument and makes it easier to draw in that relative coordinate system:



                  documentclassbeamer
                  usepackage[T1]fontenc
                  usepackagetikz

                  usetikzlibrarycalc

                  tikzset
                  use node cs/.style=shift=(#1.south west),x=(#1.south east),y=(#1.north west)


                  begindocument
                  beginframe
                  begintikzpicture
                  node[anchor = south west, inner sep = 0,opacity=0] (image) includegraphics[width = 0.8paperwidth, height = 10cm, keepaspectratio] Effile.jpeg;

                  clip (image.south west) rectangle (image.north east);

                  foreach myDim [count=i] in0,...,30
                  clip<i>[use node cs=image] let
                  n1=max(myDim,0),
                  n2=max(myDim - 1,0),
                  n3=max(myDim - 2,0),
                  n4=max(myDim - 3,0),
                  n5=max(myDim - 4,0)
                  in
                  (0.1,0.2) circle (n1 mm)
                  (0.6,0.4) circle (n2 mm)
                  (0.8,0.2) circle (n5 mm)
                  (0.5,0.3) circle (n1 mm)
                  (0.1,0.8) circle (n5 mm)
                  (0.4,0.9) circle (n3 mm)
                  (0.7,0.7) circle (n1 mm)
                  (0.2,0.5) circle (n3 mm)
                  (0.9,0.6) circle (n2 mm)
                  (0.9,0.8) circle (n1 mm);

                  node[anchor = south west, inner sep = 0] includegraphics[width = 0.8paperwidth, height = 10cm, keepaspectratio] Effile.jpeg;

                  endtikzpicture
                  endframe
                  enddocument





                  share|improve this answer
























                    up vote
                    19
                    down vote



                    accepted







                    up vote
                    19
                    down vote



                    accepted






                    Edit
                    With the overlay-beamer-styles library this can be done quite elegantly.
                    Apparently one does not need the overlay-beamer-styles library, because the Tikz macros work with the overlay syntax of beamer!



                    I include the image in the same way, but name the node image. Also, it doesn't matter where the node is placed.



                    begintikzpicture
                    node[anchor = south west, inner sep = 0] (image) includegraphics[width = 0.8paperwidth, height = 10cm, keepaspectratio] Effile.jpeg;


                    Then I can define a scope that has (0,0) in the bottom left corner of image, (1,0) in the bottom right corner, (0,1) in the top left corner and (1,1) in the top right corner.



                     beginscope[shift=(image.south west),x=(image.south east),y=(image.north west)]


                    Drawing a grid that scales with the image is now straightforward. This makes it easy to recognize the place of the paths needed in the next step.



                     % Draw a overlaying grid to easily see where the rectangles must be, this can be commented out in the final version
                    draw foreach xy in 0,0.1,...,1.001
                    (xy,0) -- node[pos=0,below]pgfmathprintnumberxy (xy,1)
                    (0,xy) -- node[pos=0,left]pgfmathprintnumberxy (1,xy);


                    Having identified the paths of the segment I want to highlight, I can add these to my foreach loop, which draws a big white rectangle on top of the image, excludes the path I specified, and draws an additional red rectangle around the highlighted segment. Additionally, the overlay-beamer-styles library provides the visible on=<> key, which can be used with the counter in the foreach.



                     foreach[count=i] mypath in 
                    (0.1,0.55) rectangle (0.25,0.65),
                    (0.45,0.85) rectangle (0.6,0.95),
                    (0.5,0.5) circle (1cm),
                    (0.75,0.3) rectangle (0.85,0.35) (0.25,0.75) circle (1.5cm)

                    filldraw<i>[white,opacity=0.75,even odd rule] (0,0) rectangle (1,1) mypath;
                    draw<i>[red,ultra thick] mypath;



                    Finally close the scope and the tikzpicture.



                     endscope
                    endtikzpicture


                    This results in:



                    enter image description here



                    where the grid is still visible, and the white rectangle is 'see-through', but for a final version this can be made opaque and the grid can be hidden.



                    enter image description here



                    Total MWE (also note that I draw the grid on top of the images and white rectangle, because otherwise it would not be very helpful):



                    documentclassbeamer
                    usepackage[T1]fontenc
                    usepackagetikz

                    begindocument
                    beginframe
                    begintikzpicture
                    node[anchor = south west, inner sep = 0] (image) includegraphics[width = 0.8paperwidth, height = 10cm, keepaspectratio] Effile.jpeg;

                    beginscope[shift=(image.south west),x=(image.south east),y=(image.north west)]

                    foreach[count=i] mypath in
                    (0.1,0.55) rectangle (0.25,0.65),
                    (0.45,0.85) rectangle (0.6,0.95),
                    (0.5,0.5) circle (1cm),
                    (0.75,0.3) rectangle (0.85,0.35) (0.25,0.75) circle (1.5cm)

                    filldraw<i>[white,even odd rule] (0,0) rectangle (1,1) mypath;
                    draw<i>[red,ultra thick] mypath;


                    % Draw a overlaying grid to easily see where the rectangles must be, this can be commented out in the final version
                    % draw foreach xy in 0,0.1,...,1.001
                    % (xy,0) -- node[pos=0,below]pgfmathprintnumberxy (xy,1)
                    % (0,xy) -- node[pos=0,left]pgfmathprintnumberxy (1,xy);
                    endscope

                    endtikzpicture
                    endframe
                    enddocument


                    Edit 2

                    Due to the fancy example shown by @marmot in his answer, I had to add something fancy myself :)



                    enter image description here



                    This can be done with:



                    documentclassbeamer
                    usepackage[T1]fontenc
                    usepackagetikz

                    begindocument
                    beginframe
                    begintikzpicture
                    node[anchor = south west, inner sep = 0] (image) includegraphics[width = 0.8paperwidth, height = 10cm, keepaspectratio] Effile.jpeg;

                    beginscope[shift=(image.south west),x=(image.south east),y=(image.north west)]
                    clip (0,0) rectangle (1,1);
                    foreach[count=i] myDim in 0,5,...,106
                    beginscope[shift=(0.5,0.5)]
                    filldraw<i>[white,opacity=1,even odd rule,] (-0.5,-0.5) rectangle (0.5,0.5) (0,1.38*myDim mm)
                    -- ++(288:myDim mm) -- ++( 0:myDim mm)
                    -- ++(216:myDim mm) -- ++(288:myDim mm)
                    -- ++(144:myDim mm) -- ++(216:myDim mm)
                    -- ++( 72:myDim mm) -- ++(144:myDim mm)
                    -- ++( 0:myDim mm) -- cycle;
                    draw<i>[red,ultra thick] (0,1.38*myDim mm)
                    -- ++(288:myDim mm) -- ++( 0:myDim mm)
                    -- ++(216:myDim mm) -- ++(288:myDim mm)
                    -- ++(144:myDim mm) -- ++(216:myDim mm)
                    -- ++( 72:myDim mm) -- ++(144:myDim mm)
                    -- ++( 0:myDim mm) -- cycle;
                    endscope

                    endscope

                    endtikzpicture
                    endframe
                    enddocument


                    Edit 3

                    This will (probably (maybe)) be the last one:



                    enter image description here



                    Done with:



                    documentclassbeamer
                    usepackage[T1]fontenc
                    usepackagetikz

                    usetikzlibraryshapes

                    begindocument
                    beginframe
                    begintikzpicture
                    node[anchor = south west, inner sep = 0,outer sep=0.5pgflinewidth] (image) includegraphics[width = 0.8paperwidth, height = 10cm, keepaspectratio] Effile.jpeg;

                    clip (image.south west) rectangle (image.north east);

                    foreach[count=k] myDim in 0,0.2,...,3.4
                    ifnumk>1
                    defmypath
                    [scale=myDim^2] (image.center)
                    foreach myPhi [count=i,evaluate=i as j using 0.5*mod(i,2)+0.5] in 0,36,...,359
                    ifnumi=1
                    +(90+50*sqrt(k)+myPhi:j)
                    else
                    -- +(90+50*sqrt(k)+myPhi:j)
                    fi
                    -- cycle

                    else
                    defmypath
                    fi

                    filldraw<k>[white]
                    (image.south west) rectangle (image.north east) mypath;
                    draw<k>[red,ultra thick] mypath;


                    endtikzpicture
                    endframe
                    enddocument


                    Edit 4

                    This really is the final one:



                    enter image description here



                    Done with the clip command (sneakingly stolen from @marmot's answer). Also I defined a use node cs style which takes a node name as argument and makes it easier to draw in that relative coordinate system:



                    documentclassbeamer
                    usepackage[T1]fontenc
                    usepackagetikz

                    usetikzlibrarycalc

                    tikzset
                    use node cs/.style=shift=(#1.south west),x=(#1.south east),y=(#1.north west)


                    begindocument
                    beginframe
                    begintikzpicture
                    node[anchor = south west, inner sep = 0,opacity=0] (image) includegraphics[width = 0.8paperwidth, height = 10cm, keepaspectratio] Effile.jpeg;

                    clip (image.south west) rectangle (image.north east);

                    foreach myDim [count=i] in0,...,30
                    clip<i>[use node cs=image] let
                    n1=max(myDim,0),
                    n2=max(myDim - 1,0),
                    n3=max(myDim - 2,0),
                    n4=max(myDim - 3,0),
                    n5=max(myDim - 4,0)
                    in
                    (0.1,0.2) circle (n1 mm)
                    (0.6,0.4) circle (n2 mm)
                    (0.8,0.2) circle (n5 mm)
                    (0.5,0.3) circle (n1 mm)
                    (0.1,0.8) circle (n5 mm)
                    (0.4,0.9) circle (n3 mm)
                    (0.7,0.7) circle (n1 mm)
                    (0.2,0.5) circle (n3 mm)
                    (0.9,0.6) circle (n2 mm)
                    (0.9,0.8) circle (n1 mm);

                    node[anchor = south west, inner sep = 0] includegraphics[width = 0.8paperwidth, height = 10cm, keepaspectratio] Effile.jpeg;

                    endtikzpicture
                    endframe
                    enddocument





                    share|improve this answer














                    Edit
                    With the overlay-beamer-styles library this can be done quite elegantly.
                    Apparently one does not need the overlay-beamer-styles library, because the Tikz macros work with the overlay syntax of beamer!



                    I include the image in the same way, but name the node image. Also, it doesn't matter where the node is placed.



                    begintikzpicture
                    node[anchor = south west, inner sep = 0] (image) includegraphics[width = 0.8paperwidth, height = 10cm, keepaspectratio] Effile.jpeg;


                    Then I can define a scope that has (0,0) in the bottom left corner of image, (1,0) in the bottom right corner, (0,1) in the top left corner and (1,1) in the top right corner.



                     beginscope[shift=(image.south west),x=(image.south east),y=(image.north west)]


                    Drawing a grid that scales with the image is now straightforward. This makes it easy to recognize the place of the paths needed in the next step.



                     % Draw a overlaying grid to easily see where the rectangles must be, this can be commented out in the final version
                    draw foreach xy in 0,0.1,...,1.001
                    (xy,0) -- node[pos=0,below]pgfmathprintnumberxy (xy,1)
                    (0,xy) -- node[pos=0,left]pgfmathprintnumberxy (1,xy);


                    Having identified the paths of the segment I want to highlight, I can add these to my foreach loop, which draws a big white rectangle on top of the image, excludes the path I specified, and draws an additional red rectangle around the highlighted segment. Additionally, the overlay-beamer-styles library provides the visible on=<> key, which can be used with the counter in the foreach.



                     foreach[count=i] mypath in 
                    (0.1,0.55) rectangle (0.25,0.65),
                    (0.45,0.85) rectangle (0.6,0.95),
                    (0.5,0.5) circle (1cm),
                    (0.75,0.3) rectangle (0.85,0.35) (0.25,0.75) circle (1.5cm)

                    filldraw<i>[white,opacity=0.75,even odd rule] (0,0) rectangle (1,1) mypath;
                    draw<i>[red,ultra thick] mypath;



                    Finally close the scope and the tikzpicture.



                     endscope
                    endtikzpicture


                    This results in:



                    enter image description here



                    where the grid is still visible, and the white rectangle is 'see-through', but for a final version this can be made opaque and the grid can be hidden.



                    enter image description here



                    Total MWE (also note that I draw the grid on top of the images and white rectangle, because otherwise it would not be very helpful):



                    documentclassbeamer
                    usepackage[T1]fontenc
                    usepackagetikz

                    begindocument
                    beginframe
                    begintikzpicture
                    node[anchor = south west, inner sep = 0] (image) includegraphics[width = 0.8paperwidth, height = 10cm, keepaspectratio] Effile.jpeg;

                    beginscope[shift=(image.south west),x=(image.south east),y=(image.north west)]

                    foreach[count=i] mypath in
                    (0.1,0.55) rectangle (0.25,0.65),
                    (0.45,0.85) rectangle (0.6,0.95),
                    (0.5,0.5) circle (1cm),
                    (0.75,0.3) rectangle (0.85,0.35) (0.25,0.75) circle (1.5cm)

                    filldraw<i>[white,even odd rule] (0,0) rectangle (1,1) mypath;
                    draw<i>[red,ultra thick] mypath;


                    % Draw a overlaying grid to easily see where the rectangles must be, this can be commented out in the final version
                    % draw foreach xy in 0,0.1,...,1.001
                    % (xy,0) -- node[pos=0,below]pgfmathprintnumberxy (xy,1)
                    % (0,xy) -- node[pos=0,left]pgfmathprintnumberxy (1,xy);
                    endscope

                    endtikzpicture
                    endframe
                    enddocument


                    Edit 2

                    Due to the fancy example shown by @marmot in his answer, I had to add something fancy myself :)



                    enter image description here



                    This can be done with:



                    documentclassbeamer
                    usepackage[T1]fontenc
                    usepackagetikz

                    begindocument
                    beginframe
                    begintikzpicture
                    node[anchor = south west, inner sep = 0] (image) includegraphics[width = 0.8paperwidth, height = 10cm, keepaspectratio] Effile.jpeg;

                    beginscope[shift=(image.south west),x=(image.south east),y=(image.north west)]
                    clip (0,0) rectangle (1,1);
                    foreach[count=i] myDim in 0,5,...,106
                    beginscope[shift=(0.5,0.5)]
                    filldraw<i>[white,opacity=1,even odd rule,] (-0.5,-0.5) rectangle (0.5,0.5) (0,1.38*myDim mm)
                    -- ++(288:myDim mm) -- ++( 0:myDim mm)
                    -- ++(216:myDim mm) -- ++(288:myDim mm)
                    -- ++(144:myDim mm) -- ++(216:myDim mm)
                    -- ++( 72:myDim mm) -- ++(144:myDim mm)
                    -- ++( 0:myDim mm) -- cycle;
                    draw<i>[red,ultra thick] (0,1.38*myDim mm)
                    -- ++(288:myDim mm) -- ++( 0:myDim mm)
                    -- ++(216:myDim mm) -- ++(288:myDim mm)
                    -- ++(144:myDim mm) -- ++(216:myDim mm)
                    -- ++( 72:myDim mm) -- ++(144:myDim mm)
                    -- ++( 0:myDim mm) -- cycle;
                    endscope

                    endscope

                    endtikzpicture
                    endframe
                    enddocument


                    Edit 3

                    This will (probably (maybe)) be the last one:



                    enter image description here



                    Done with:



                    documentclassbeamer
                    usepackage[T1]fontenc
                    usepackagetikz

                    usetikzlibraryshapes

                    begindocument
                    beginframe
                    begintikzpicture
                    node[anchor = south west, inner sep = 0,outer sep=0.5pgflinewidth] (image) includegraphics[width = 0.8paperwidth, height = 10cm, keepaspectratio] Effile.jpeg;

                    clip (image.south west) rectangle (image.north east);

                    foreach[count=k] myDim in 0,0.2,...,3.4
                    ifnumk>1
                    defmypath
                    [scale=myDim^2] (image.center)
                    foreach myPhi [count=i,evaluate=i as j using 0.5*mod(i,2)+0.5] in 0,36,...,359
                    ifnumi=1
                    +(90+50*sqrt(k)+myPhi:j)
                    else
                    -- +(90+50*sqrt(k)+myPhi:j)
                    fi
                    -- cycle

                    else
                    defmypath
                    fi

                    filldraw<k>[white]
                    (image.south west) rectangle (image.north east) mypath;
                    draw<k>[red,ultra thick] mypath;


                    endtikzpicture
                    endframe
                    enddocument


                    Edit 4

                    This really is the final one:



                    enter image description here



                    Done with the clip command (sneakingly stolen from @marmot's answer). Also I defined a use node cs style which takes a node name as argument and makes it easier to draw in that relative coordinate system:



                    documentclassbeamer
                    usepackage[T1]fontenc
                    usepackagetikz

                    usetikzlibrarycalc

                    tikzset
                    use node cs/.style=shift=(#1.south west),x=(#1.south east),y=(#1.north west)


                    begindocument
                    beginframe
                    begintikzpicture
                    node[anchor = south west, inner sep = 0,opacity=0] (image) includegraphics[width = 0.8paperwidth, height = 10cm, keepaspectratio] Effile.jpeg;

                    clip (image.south west) rectangle (image.north east);

                    foreach myDim [count=i] in0,...,30
                    clip<i>[use node cs=image] let
                    n1=max(myDim,0),
                    n2=max(myDim - 1,0),
                    n3=max(myDim - 2,0),
                    n4=max(myDim - 3,0),
                    n5=max(myDim - 4,0)
                    in
                    (0.1,0.2) circle (n1 mm)
                    (0.6,0.4) circle (n2 mm)
                    (0.8,0.2) circle (n5 mm)
                    (0.5,0.3) circle (n1 mm)
                    (0.1,0.8) circle (n5 mm)
                    (0.4,0.9) circle (n3 mm)
                    (0.7,0.7) circle (n1 mm)
                    (0.2,0.5) circle (n3 mm)
                    (0.9,0.6) circle (n2 mm)
                    (0.9,0.8) circle (n1 mm);

                    node[anchor = south west, inner sep = 0] includegraphics[width = 0.8paperwidth, height = 10cm, keepaspectratio] Effile.jpeg;

                    endtikzpicture
                    endframe
                    enddocument






                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Aug 14 at 14:34

























                    answered Aug 13 at 9:24









                    Max

                    5,02311525




                    5,02311525




















                        up vote
                        12
                        down vote













                        I think Max gave you already a perfect answer. This here is just for fun and to show a slightly different approach using clip. You could just clip the desired regions using only.



                        documentclassbeamer
                        usepackagetikz

                        begindocument

                        beginframe

                        begintikzpicture
                        coordinate (O) at (0,0);
                        node[anchor = south west, inner sep = 0,opacity=0] (A) at (O) includegraphics[width = 0.8paperwidth, height = 10cm, keepaspectratio]Effile.jpeg;
                        only<1>clip (A.center) circle (1cm);
                        only<2>clip (A.center) circle (2cm);
                        only<3>clip (1.05, 5.1) rectangle (2.49, 4.3);
                        only<4>
                        node[anchor = south west, inner sep = 0] at (O) includegraphics[width = 0.8paperwidth, height = 10cm, keepaspectratio]Effile.jpeg;
                        only<3>draw[red, ultra thick] (1.05, 5.1) rectangle (2.49, 4.3);
                        endtikzpicture
                        endframe
                        enddocument


                        enter image description here



                        And one can of course get rid of only and do other things like this.



                        documentclassbeamer
                        usepackagetikz

                        begindocument

                        beginframe

                        begintikzpicture
                        coordinate (O) at (0,0);
                        node[anchor = south west, inner sep = 0,opacity=0] (A) at (O) includegraphics[width = 0.8paperwidth, height = 10cm, keepaspectratio]Effile.jpeg;
                        foreach X [count=Y] in 0.9,0.8,...,0.1

                        path (A.south west) -- (A.north east) coordinate[pos=X*0.5] (BL)
                        coordinate[pos=1-0.5*X] (TR);
                        clip<Y> (BL) rectangle (TR);

                        node[anchor = south west, inner sep = 0] at (O) includegraphics[width = 0.8paperwidth, height = 10cm, keepaspectratio]Effile.jpeg;
                        endtikzpicture
                        endframe
                        enddocument


                        enter image description here



                        EDIT: I hadn't seen Max' super nice updates. So I had to rewrite his nice star code in a somewhat shorter way. One can load shapes.geometric, which also has a star (and many other shapes), and use path picture to clip the pic against that shape. ;-)



                        documentclassbeamer
                        usepackagetikz
                        usetikzlibraryshapes.geometric
                        begindocument
                        beginframe
                        begintikzpicture
                        path[use as bounding box] (-6,-4) rectangle (6,4);
                        foreach X [count=Y]in 2,2.4,...,16
                        node<Y> [rotate=X*60,star, star point height=0.25*X cm, minimum size=X cm, draw,
                        path picture=
                        nodeincludegraphics[width = 0.8paperwidth, height = 10cm,
                        keepaspectratio] Effile.jpeg;]
                        (image) ;
                        endtikzpicture
                        endframe
                        enddocument


                        enter image description here






                        share|improve this answer


























                          up vote
                          12
                          down vote













                          I think Max gave you already a perfect answer. This here is just for fun and to show a slightly different approach using clip. You could just clip the desired regions using only.



                          documentclassbeamer
                          usepackagetikz

                          begindocument

                          beginframe

                          begintikzpicture
                          coordinate (O) at (0,0);
                          node[anchor = south west, inner sep = 0,opacity=0] (A) at (O) includegraphics[width = 0.8paperwidth, height = 10cm, keepaspectratio]Effile.jpeg;
                          only<1>clip (A.center) circle (1cm);
                          only<2>clip (A.center) circle (2cm);
                          only<3>clip (1.05, 5.1) rectangle (2.49, 4.3);
                          only<4>
                          node[anchor = south west, inner sep = 0] at (O) includegraphics[width = 0.8paperwidth, height = 10cm, keepaspectratio]Effile.jpeg;
                          only<3>draw[red, ultra thick] (1.05, 5.1) rectangle (2.49, 4.3);
                          endtikzpicture
                          endframe
                          enddocument


                          enter image description here



                          And one can of course get rid of only and do other things like this.



                          documentclassbeamer
                          usepackagetikz

                          begindocument

                          beginframe

                          begintikzpicture
                          coordinate (O) at (0,0);
                          node[anchor = south west, inner sep = 0,opacity=0] (A) at (O) includegraphics[width = 0.8paperwidth, height = 10cm, keepaspectratio]Effile.jpeg;
                          foreach X [count=Y] in 0.9,0.8,...,0.1

                          path (A.south west) -- (A.north east) coordinate[pos=X*0.5] (BL)
                          coordinate[pos=1-0.5*X] (TR);
                          clip<Y> (BL) rectangle (TR);

                          node[anchor = south west, inner sep = 0] at (O) includegraphics[width = 0.8paperwidth, height = 10cm, keepaspectratio]Effile.jpeg;
                          endtikzpicture
                          endframe
                          enddocument


                          enter image description here



                          EDIT: I hadn't seen Max' super nice updates. So I had to rewrite his nice star code in a somewhat shorter way. One can load shapes.geometric, which also has a star (and many other shapes), and use path picture to clip the pic against that shape. ;-)



                          documentclassbeamer
                          usepackagetikz
                          usetikzlibraryshapes.geometric
                          begindocument
                          beginframe
                          begintikzpicture
                          path[use as bounding box] (-6,-4) rectangle (6,4);
                          foreach X [count=Y]in 2,2.4,...,16
                          node<Y> [rotate=X*60,star, star point height=0.25*X cm, minimum size=X cm, draw,
                          path picture=
                          nodeincludegraphics[width = 0.8paperwidth, height = 10cm,
                          keepaspectratio] Effile.jpeg;]
                          (image) ;
                          endtikzpicture
                          endframe
                          enddocument


                          enter image description here






                          share|improve this answer
























                            up vote
                            12
                            down vote










                            up vote
                            12
                            down vote









                            I think Max gave you already a perfect answer. This here is just for fun and to show a slightly different approach using clip. You could just clip the desired regions using only.



                            documentclassbeamer
                            usepackagetikz

                            begindocument

                            beginframe

                            begintikzpicture
                            coordinate (O) at (0,0);
                            node[anchor = south west, inner sep = 0,opacity=0] (A) at (O) includegraphics[width = 0.8paperwidth, height = 10cm, keepaspectratio]Effile.jpeg;
                            only<1>clip (A.center) circle (1cm);
                            only<2>clip (A.center) circle (2cm);
                            only<3>clip (1.05, 5.1) rectangle (2.49, 4.3);
                            only<4>
                            node[anchor = south west, inner sep = 0] at (O) includegraphics[width = 0.8paperwidth, height = 10cm, keepaspectratio]Effile.jpeg;
                            only<3>draw[red, ultra thick] (1.05, 5.1) rectangle (2.49, 4.3);
                            endtikzpicture
                            endframe
                            enddocument


                            enter image description here



                            And one can of course get rid of only and do other things like this.



                            documentclassbeamer
                            usepackagetikz

                            begindocument

                            beginframe

                            begintikzpicture
                            coordinate (O) at (0,0);
                            node[anchor = south west, inner sep = 0,opacity=0] (A) at (O) includegraphics[width = 0.8paperwidth, height = 10cm, keepaspectratio]Effile.jpeg;
                            foreach X [count=Y] in 0.9,0.8,...,0.1

                            path (A.south west) -- (A.north east) coordinate[pos=X*0.5] (BL)
                            coordinate[pos=1-0.5*X] (TR);
                            clip<Y> (BL) rectangle (TR);

                            node[anchor = south west, inner sep = 0] at (O) includegraphics[width = 0.8paperwidth, height = 10cm, keepaspectratio]Effile.jpeg;
                            endtikzpicture
                            endframe
                            enddocument


                            enter image description here



                            EDIT: I hadn't seen Max' super nice updates. So I had to rewrite his nice star code in a somewhat shorter way. One can load shapes.geometric, which also has a star (and many other shapes), and use path picture to clip the pic against that shape. ;-)



                            documentclassbeamer
                            usepackagetikz
                            usetikzlibraryshapes.geometric
                            begindocument
                            beginframe
                            begintikzpicture
                            path[use as bounding box] (-6,-4) rectangle (6,4);
                            foreach X [count=Y]in 2,2.4,...,16
                            node<Y> [rotate=X*60,star, star point height=0.25*X cm, minimum size=X cm, draw,
                            path picture=
                            nodeincludegraphics[width = 0.8paperwidth, height = 10cm,
                            keepaspectratio] Effile.jpeg;]
                            (image) ;
                            endtikzpicture
                            endframe
                            enddocument


                            enter image description here






                            share|improve this answer














                            I think Max gave you already a perfect answer. This here is just for fun and to show a slightly different approach using clip. You could just clip the desired regions using only.



                            documentclassbeamer
                            usepackagetikz

                            begindocument

                            beginframe

                            begintikzpicture
                            coordinate (O) at (0,0);
                            node[anchor = south west, inner sep = 0,opacity=0] (A) at (O) includegraphics[width = 0.8paperwidth, height = 10cm, keepaspectratio]Effile.jpeg;
                            only<1>clip (A.center) circle (1cm);
                            only<2>clip (A.center) circle (2cm);
                            only<3>clip (1.05, 5.1) rectangle (2.49, 4.3);
                            only<4>
                            node[anchor = south west, inner sep = 0] at (O) includegraphics[width = 0.8paperwidth, height = 10cm, keepaspectratio]Effile.jpeg;
                            only<3>draw[red, ultra thick] (1.05, 5.1) rectangle (2.49, 4.3);
                            endtikzpicture
                            endframe
                            enddocument


                            enter image description here



                            And one can of course get rid of only and do other things like this.



                            documentclassbeamer
                            usepackagetikz

                            begindocument

                            beginframe

                            begintikzpicture
                            coordinate (O) at (0,0);
                            node[anchor = south west, inner sep = 0,opacity=0] (A) at (O) includegraphics[width = 0.8paperwidth, height = 10cm, keepaspectratio]Effile.jpeg;
                            foreach X [count=Y] in 0.9,0.8,...,0.1

                            path (A.south west) -- (A.north east) coordinate[pos=X*0.5] (BL)
                            coordinate[pos=1-0.5*X] (TR);
                            clip<Y> (BL) rectangle (TR);

                            node[anchor = south west, inner sep = 0] at (O) includegraphics[width = 0.8paperwidth, height = 10cm, keepaspectratio]Effile.jpeg;
                            endtikzpicture
                            endframe
                            enddocument


                            enter image description here



                            EDIT: I hadn't seen Max' super nice updates. So I had to rewrite his nice star code in a somewhat shorter way. One can load shapes.geometric, which also has a star (and many other shapes), and use path picture to clip the pic against that shape. ;-)



                            documentclassbeamer
                            usepackagetikz
                            usetikzlibraryshapes.geometric
                            begindocument
                            beginframe
                            begintikzpicture
                            path[use as bounding box] (-6,-4) rectangle (6,4);
                            foreach X [count=Y]in 2,2.4,...,16
                            node<Y> [rotate=X*60,star, star point height=0.25*X cm, minimum size=X cm, draw,
                            path picture=
                            nodeincludegraphics[width = 0.8paperwidth, height = 10cm,
                            keepaspectratio] Effile.jpeg;]
                            (image) ;
                            endtikzpicture
                            endframe
                            enddocument


                            enter image description here







                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited Aug 14 at 20:36

























                            answered Aug 13 at 12:15









                            marmot

                            52.1k453114




                            52.1k453114




















                                up vote
                                4
                                down vote













                                May be this could help. By properly naming the node you can use a fill=<color> with fill opacity=<num>. By naming the node we can easily access the coordinates of the vertices, thereby, we can flow-through the region we want:



                                documentclassbeamer
                                usepackage[T1]fontenc
                                usepackagetikz

                                begindocument

                                beginframe
                                % yes this is the original pic just for comparing
                                begintikzpicture
                                node[anchor = south west, inner sep = 0] (A) at (0, 0) includegraphics[width = 0.2paperwidth, height = 10cm, keepaspectratio]example-image-a;

                                endtikzpicture
                                % the actual stuff, the highlighted picture!
                                begintikzpicture
                                node[anchor = south west, inner sep = 0] (A) at (0, 0) includegraphics[width = 0.2paperwidth, height = 10cm, keepaspectratio]example-image-a;

                                draw[red,ultra thick] (0,0) rectangle (0.5,0.5);
                                fill [draw=none, fill=white, fill opacity=1]
                                (0,0.5) --
                                (A.north west) -- (A.north east) -- (A.south east) --
                                (0.5,0) -- (0.5,0.5) -- cycle;

                                endtikzpicture

                                endframe

                                enddocument


                                which gives you:



                                enter image description here






                                share|improve this answer


























                                  up vote
                                  4
                                  down vote













                                  May be this could help. By properly naming the node you can use a fill=<color> with fill opacity=<num>. By naming the node we can easily access the coordinates of the vertices, thereby, we can flow-through the region we want:



                                  documentclassbeamer
                                  usepackage[T1]fontenc
                                  usepackagetikz

                                  begindocument

                                  beginframe
                                  % yes this is the original pic just for comparing
                                  begintikzpicture
                                  node[anchor = south west, inner sep = 0] (A) at (0, 0) includegraphics[width = 0.2paperwidth, height = 10cm, keepaspectratio]example-image-a;

                                  endtikzpicture
                                  % the actual stuff, the highlighted picture!
                                  begintikzpicture
                                  node[anchor = south west, inner sep = 0] (A) at (0, 0) includegraphics[width = 0.2paperwidth, height = 10cm, keepaspectratio]example-image-a;

                                  draw[red,ultra thick] (0,0) rectangle (0.5,0.5);
                                  fill [draw=none, fill=white, fill opacity=1]
                                  (0,0.5) --
                                  (A.north west) -- (A.north east) -- (A.south east) --
                                  (0.5,0) -- (0.5,0.5) -- cycle;

                                  endtikzpicture

                                  endframe

                                  enddocument


                                  which gives you:



                                  enter image description here






                                  share|improve this answer
























                                    up vote
                                    4
                                    down vote










                                    up vote
                                    4
                                    down vote









                                    May be this could help. By properly naming the node you can use a fill=<color> with fill opacity=<num>. By naming the node we can easily access the coordinates of the vertices, thereby, we can flow-through the region we want:



                                    documentclassbeamer
                                    usepackage[T1]fontenc
                                    usepackagetikz

                                    begindocument

                                    beginframe
                                    % yes this is the original pic just for comparing
                                    begintikzpicture
                                    node[anchor = south west, inner sep = 0] (A) at (0, 0) includegraphics[width = 0.2paperwidth, height = 10cm, keepaspectratio]example-image-a;

                                    endtikzpicture
                                    % the actual stuff, the highlighted picture!
                                    begintikzpicture
                                    node[anchor = south west, inner sep = 0] (A) at (0, 0) includegraphics[width = 0.2paperwidth, height = 10cm, keepaspectratio]example-image-a;

                                    draw[red,ultra thick] (0,0) rectangle (0.5,0.5);
                                    fill [draw=none, fill=white, fill opacity=1]
                                    (0,0.5) --
                                    (A.north west) -- (A.north east) -- (A.south east) --
                                    (0.5,0) -- (0.5,0.5) -- cycle;

                                    endtikzpicture

                                    endframe

                                    enddocument


                                    which gives you:



                                    enter image description here






                                    share|improve this answer














                                    May be this could help. By properly naming the node you can use a fill=<color> with fill opacity=<num>. By naming the node we can easily access the coordinates of the vertices, thereby, we can flow-through the region we want:



                                    documentclassbeamer
                                    usepackage[T1]fontenc
                                    usepackagetikz

                                    begindocument

                                    beginframe
                                    % yes this is the original pic just for comparing
                                    begintikzpicture
                                    node[anchor = south west, inner sep = 0] (A) at (0, 0) includegraphics[width = 0.2paperwidth, height = 10cm, keepaspectratio]example-image-a;

                                    endtikzpicture
                                    % the actual stuff, the highlighted picture!
                                    begintikzpicture
                                    node[anchor = south west, inner sep = 0] (A) at (0, 0) includegraphics[width = 0.2paperwidth, height = 10cm, keepaspectratio]example-image-a;

                                    draw[red,ultra thick] (0,0) rectangle (0.5,0.5);
                                    fill [draw=none, fill=white, fill opacity=1]
                                    (0,0.5) --
                                    (A.north west) -- (A.north east) -- (A.south east) --
                                    (0.5,0) -- (0.5,0.5) -- cycle;

                                    endtikzpicture

                                    endframe

                                    enddocument


                                    which gives you:



                                    enter image description here







                                    share|improve this answer














                                    share|improve this answer



                                    share|improve this answer








                                    edited Aug 13 at 8:43

























                                    answered Aug 13 at 8:38









                                    Raaja

                                    1,4501522




                                    1,4501522






















                                         

                                        draft saved


                                        draft discarded


























                                         


                                        draft saved


                                        draft discarded














                                        StackExchange.ready(
                                        function ()
                                        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f445840%2fbeamer-highlighting-some-part-of-an-image-and-hiding-remaining-part%23new-answer', 'question_page');

                                        );

                                        Post as a guest













































































                                        這個網誌中的熱門文章

                                        How to combine Bézier curves to a surface?

                                        Mutual Information Always Non-negative

                                        Why am i infinitely getting the same tweet with the Twitter Search API?