Pergunta

Quando aplico um filtro SVG em escala de escala em uma imagem escura, recebo faixas significativas nos resultados. O filtro que estou usando é:

     <!doctype html>
     <html>
     <head>
     <style>
      img {
     filter: url(#grayscale); /* Firefox */     
     filter: gray; /* IE */
    -webkit-filter: grayscale(1); /* Webkit */
    }
      img:hover {
    filter: none;
    -webkit-filter: grayscale(0);
    }
       </style>
    </head>
  <body>
  <img src="http://www.walldoze.com/static/cache/2048x2048/hd-wallpapers-space-iphone-  wallpaper-retina-2048x2048-wallpaper.jpg" width="1000">
  <svg xmlns="http://www.w3.org/2000/svg">
 <filter id="grayscale" >
 <feColorMatrix type="matrix"  values="0.3333 0.3333 0.3333 0 0.001 0.3333 0.3333 0.3333 0 0.001 0.3333 0.3333 0.3333 0 0.001 0 0 0 1 0.001"/>
  </filter>
  </svg>
  </body>
  </html>

enter image description here

Foi útil?

Solução

Para obter melhor desempenho, você pode definir o atributo Filters de Interpolação de Cor para "SRGB" na propriedade Filter:

<filter id="greyscale" color-interpolation-filters="sRGB">
  <feColorMatrix type="saturate" values="0"/>
</filter>

Os filtros de interpolação de cores não são suportados no Safari, no entanto, com o melhor de meu conhecimento

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top