{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.LookoutVision.Types.PixelAnomaly
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.LookoutVision.Types.PixelAnomaly where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | Information about the pixels in an anomaly mask. For more information,
-- see Anomaly. @PixelAnomaly@ is only returned by image segmentation
-- models.
--
-- /See:/ 'newPixelAnomaly' smart constructor.
data PixelAnomaly = PixelAnomaly'
  { -- | A hex color value for the mask that covers an anomaly type. Each anomaly
    -- type has a different mask color. The color maps to the color of the
    -- anomaly type used in the training dataset.
    PixelAnomaly -> Maybe Text
color :: Prelude.Maybe Prelude.Text,
    -- | The percentage area of the image that the anomaly type covers.
    PixelAnomaly -> Maybe Double
totalPercentageArea :: Prelude.Maybe Prelude.Double
  }
  deriving (PixelAnomaly -> PixelAnomaly -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PixelAnomaly -> PixelAnomaly -> Bool
$c/= :: PixelAnomaly -> PixelAnomaly -> Bool
== :: PixelAnomaly -> PixelAnomaly -> Bool
$c== :: PixelAnomaly -> PixelAnomaly -> Bool
Prelude.Eq, ReadPrec [PixelAnomaly]
ReadPrec PixelAnomaly
Int -> ReadS PixelAnomaly
ReadS [PixelAnomaly]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PixelAnomaly]
$creadListPrec :: ReadPrec [PixelAnomaly]
readPrec :: ReadPrec PixelAnomaly
$creadPrec :: ReadPrec PixelAnomaly
readList :: ReadS [PixelAnomaly]
$creadList :: ReadS [PixelAnomaly]
readsPrec :: Int -> ReadS PixelAnomaly
$creadsPrec :: Int -> ReadS PixelAnomaly
Prelude.Read, Int -> PixelAnomaly -> ShowS
[PixelAnomaly] -> ShowS
PixelAnomaly -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PixelAnomaly] -> ShowS
$cshowList :: [PixelAnomaly] -> ShowS
show :: PixelAnomaly -> String
$cshow :: PixelAnomaly -> String
showsPrec :: Int -> PixelAnomaly -> ShowS
$cshowsPrec :: Int -> PixelAnomaly -> ShowS
Prelude.Show, forall x. Rep PixelAnomaly x -> PixelAnomaly
forall x. PixelAnomaly -> Rep PixelAnomaly x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PixelAnomaly x -> PixelAnomaly
$cfrom :: forall x. PixelAnomaly -> Rep PixelAnomaly x
Prelude.Generic)

-- |
-- Create a value of 'PixelAnomaly' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'color', 'pixelAnomaly_color' - A hex color value for the mask that covers an anomaly type. Each anomaly
-- type has a different mask color. The color maps to the color of the
-- anomaly type used in the training dataset.
--
-- 'totalPercentageArea', 'pixelAnomaly_totalPercentageArea' - The percentage area of the image that the anomaly type covers.
newPixelAnomaly ::
  PixelAnomaly
newPixelAnomaly :: PixelAnomaly
newPixelAnomaly =
  PixelAnomaly'
    { $sel:color:PixelAnomaly' :: Maybe Text
color = forall a. Maybe a
Prelude.Nothing,
      $sel:totalPercentageArea:PixelAnomaly' :: Maybe Double
totalPercentageArea = forall a. Maybe a
Prelude.Nothing
    }

-- | A hex color value for the mask that covers an anomaly type. Each anomaly
-- type has a different mask color. The color maps to the color of the
-- anomaly type used in the training dataset.
pixelAnomaly_color :: Lens.Lens' PixelAnomaly (Prelude.Maybe Prelude.Text)
pixelAnomaly_color :: Lens' PixelAnomaly (Maybe Text)
pixelAnomaly_color = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PixelAnomaly' {Maybe Text
color :: Maybe Text
$sel:color:PixelAnomaly' :: PixelAnomaly -> Maybe Text
color} -> Maybe Text
color) (\s :: PixelAnomaly
s@PixelAnomaly' {} Maybe Text
a -> PixelAnomaly
s {$sel:color:PixelAnomaly' :: Maybe Text
color = Maybe Text
a} :: PixelAnomaly)

-- | The percentage area of the image that the anomaly type covers.
pixelAnomaly_totalPercentageArea :: Lens.Lens' PixelAnomaly (Prelude.Maybe Prelude.Double)
pixelAnomaly_totalPercentageArea :: Lens' PixelAnomaly (Maybe Double)
pixelAnomaly_totalPercentageArea = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PixelAnomaly' {Maybe Double
totalPercentageArea :: Maybe Double
$sel:totalPercentageArea:PixelAnomaly' :: PixelAnomaly -> Maybe Double
totalPercentageArea} -> Maybe Double
totalPercentageArea) (\s :: PixelAnomaly
s@PixelAnomaly' {} Maybe Double
a -> PixelAnomaly
s {$sel:totalPercentageArea:PixelAnomaly' :: Maybe Double
totalPercentageArea = Maybe Double
a} :: PixelAnomaly)

instance Data.FromJSON PixelAnomaly where
  parseJSON :: Value -> Parser PixelAnomaly
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"PixelAnomaly"
      ( \Object
x ->
          Maybe Text -> Maybe Double -> PixelAnomaly
PixelAnomaly'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Color")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"TotalPercentageArea")
      )

instance Prelude.Hashable PixelAnomaly where
  hashWithSalt :: Int -> PixelAnomaly -> Int
hashWithSalt Int
_salt PixelAnomaly' {Maybe Double
Maybe Text
totalPercentageArea :: Maybe Double
color :: Maybe Text
$sel:totalPercentageArea:PixelAnomaly' :: PixelAnomaly -> Maybe Double
$sel:color:PixelAnomaly' :: PixelAnomaly -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
color
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
totalPercentageArea

instance Prelude.NFData PixelAnomaly where
  rnf :: PixelAnomaly -> ()
rnf PixelAnomaly' {Maybe Double
Maybe Text
totalPercentageArea :: Maybe Double
color :: Maybe Text
$sel:totalPercentageArea:PixelAnomaly' :: PixelAnomaly -> Maybe Double
$sel:color:PixelAnomaly' :: PixelAnomaly -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
color
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
totalPercentageArea