remove_channels Subroutine

private pure elemental subroutine remove_channels(this, remove_r, remove_g, remove_b)

Removes one or more RGB channels from the image. Only supported for PPM images.

Type Bound

format_pnm

Arguments

Type IntentOptional Attributes Name
class(format_pnm), intent(inout) :: this
logical, intent(in), optional :: remove_r
logical, intent(in), optional :: remove_g
logical, intent(in), optional :: remove_b

Calls

proc~~remove_channels~~CallsGraph proc~remove_channels format_pnm%remove_channels proc~check_pixel_range format_pnm%check_pixel_range proc~remove_channels->proc~check_pixel_range

Called by

proc~~remove_channels~~CalledByGraph proc~remove_channels format_pnm%remove_channels program~demo_ppm demo_ppm program~demo_ppm->proc~remove_channels program~test20 test20 program~test20->proc~remove_channels

Source Code

   elemental pure subroutine remove_channels(this, remove_r, remove_g, remove_b)
      class(format_pnm), intent(inout) :: this
      logical, optional, intent(in)    :: remove_r, remove_g, remove_b

      ! Check if the file is ppm
      if (this%file_format /= 'ppm') error stop 'remove_channels: This function is only for ppm files.'

      ! Remove R channel
      if (present(remove_r)) then
         if (remove_r) then
            this%pixels(:,1:size(this%pixels,2):3) = 0_ik
         end if
      end if

      ! Remove G channel
      if (present(remove_g)) then
         if (remove_g) then
            this%pixels(:,2:size(this%pixels,2):3) = 0_ik
         end if
      end if

      ! Remove B channel
      if (present(remove_b)) then
         if (remove_b) then
            this%pixels(:,3:size(this%pixels,2):3) = 0_ik
         end if
      end if

      call this%check_pixel_range(this%pixels)

   end subroutine remove_channels