Skip to content

Commit

Permalink
Add files for more colormaps
Browse files Browse the repository at this point in the history
  • Loading branch information
hiromatsui committed May 24, 2024
1 parent 273f133 commit b5c71a9
Show file tree
Hide file tree
Showing 10 changed files with 529 additions and 178 deletions.
5 changes: 3 additions & 2 deletions src/C_libraries/BASE/read_image_2_png.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,13 @@ void read_png_file_c(const char *fhead, int *num_x, int *num_y, int *iflag_rgba)
read_png_image_w_gamma(fp, png_ptr, info_ptr, &bimage, &width, &height,
iflag_rgba, display_gamma);
fclose(fp);
/*
{
/* Display gAMA Chunk */
// Display gAMA Chunk
if (png_get_gAMA(png_ptr, info_ptr, &file_gamma))
printf("gamma = %lf\n", file_gamma);
}
*/
{
/* Display tEXT Chunk */
png_textp text_ptr;
Expand Down
12 changes: 11 additions & 1 deletion src/Fortran_libraries/VIZ_src/volume_rendering/Makefile.depends
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ cal_pvr_modelview_mat.o: $(PVR_DIR)/cal_pvr_modelview_mat.f90 m_precision.o m_co
$(F90) -c $(F90OPTFLAGS) $<
cal_pvr_projection_mat.o: $(PVR_DIR)/cal_pvr_projection_mat.f90 m_precision.o m_constants.o m_machine_parameter.o t_control_params_4_pvr.o t_control_params_stereo_pvr.o set_projection_matrix.o
$(F90) -c $(F90OPTFLAGS) $<
colormap_grayscales.o: $(PVR_DIR)/colormap_grayscales.f90 m_precision.o m_constants.o
$(F90) -c $(F90OPTFLAGS) $<
colormap_metal.o: $(PVR_DIR)/colormap_metal.f90 m_precision.o m_constants.o
$(F90) -c $(F90OPTFLAGS) $<
colormap_rainbow.o: $(PVR_DIR)/colormap_rainbow.f90 m_precision.o m_constants.o
$(F90) -c $(F90OPTFLAGS) $<
colormap_space.o: $(PVR_DIR)/colormap_space.f90 m_precision.o m_constants.o
$(F90) -c $(F90OPTFLAGS) $<
colormap_two_colors.o: $(PVR_DIR)/colormap_two_colors.f90 m_precision.o m_constants.o
$(F90) -c $(F90OPTFLAGS) $<
comm_tbl_4_img_composit.o: $(PVR_DIR)/comm_tbl_4_img_composit.f90 m_precision.o m_constants.o quicksort.o
$(F90) -c $(F90OPTFLAGS) $<
comm_tbl_4_img_output.o: $(PVR_DIR)/comm_tbl_4_img_output.f90 m_precision.o m_constants.o
Expand Down Expand Up @@ -88,7 +98,7 @@ rendering_vr_image.o: $(PVR_DIR)/rendering_vr_image.f90 m_precision.o m_machine_
$(F90) -c $(F90OPTFLAGS) $<
set_PVR_view_and_image.o: $(PVR_DIR)/set_PVR_view_and_image.f90 m_precision.o calypso_mpi.o m_constants.o m_machine_parameter.o m_geometry_constants.o t_mesh_data.o t_pvr_image_array.o t_rendering_vr_image.o t_surf_grp_4_pvr_domain.o t_geometries_in_pvr_screen.o t_mesh_SR.o rendering_vr_image.o cal_pvr_modelview_mat.o cal_pvr_projection_mat.o
$(F90) -c $(F90OPTFLAGS) $<
set_color_4_pvr.o: $(PVR_DIR)/set_color_4_pvr.f90 m_precision.o set_rgb_colors.o
set_color_4_pvr.o: $(PVR_DIR)/set_color_4_pvr.f90 m_precision.o set_rgb_colors.o colormap_rainbow.o colormap_two_colors.o colormap_grayscales.o colormap_metal.o colormap_space.o
$(F90) -c $(F90OPTFLAGS) $<
set_composition_pe_range.o: $(PVR_DIR)/set_composition_pe_range.f90 m_precision.o t_rendering_vr_image.o t_pvr_image_array.o
$(F90) -c $(F90OPTFLAGS) $<
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
!>@file colormap_grayscales.F90
!!@brief module colormap_grayscales
!!
!!@author H. Matsui
!!@date Programmed in Apr., 2024
!
!>@brief Colormapping for grayscales
!!
!!@verbatim
!! subroutine s_colormap_grayscale(rnorm, r, g, b)
!! subroutine s_colormap_sym_grayscale(rnorm, r, g, b)
!! real(kind = kreal), intent(in) :: rnorm
!! real(kind = kreal), intent(inout) :: r, g, b
!!@endverbatim
!
module colormap_grayscales
!
use m_precision
use m_constants
!
implicit none
!
! ------------------------------------------------------------------
!
contains
!
! ------------------------------------------------------------------
!
subroutine s_colormap_grayscale(rnorm, r, g, b)
!
real(kind = kreal), intent(in) :: rnorm
real(kind = kreal), intent(inout) :: r, g, b
!
real(kind = kreal), parameter :: black = zero
real(kind = kreal), parameter :: white = one
!
!
if (rnorm .lt. zero ) then
r = zero
g = zero
b = zero
else if (rnorm .ge. zero .and. rnorm.lt.white) then
r = 0.85d0*rnorm
g = 0.85d0*rnorm
b = 0.85d0*rnorm
else if (rnorm .ge. white ) then
r = 0.85d0
g = 0.85d0
b = 0.85d0
end if
!
end subroutine s_colormap_grayscale
!
! ----------------------------------------------------------------------
!
subroutine s_colormap_sym_grayscale(rnorm, r, g, b)
!
real(kind = kreal), intent(in) :: rnorm
real(kind = kreal), intent(inout) :: r, g, b
!
real(kind = kreal), parameter :: black = zero
real(kind = kreal), parameter :: white = one
real(kind = kreal), parameter :: half = one / two
!
!
if (rnorm .lt. zero ) then
r = zero
g = zero
b = zero
else if (rnorm .ge. zero .and. rnorm.lt.half) then
r = 0.85d0*two*rnorm
g = 0.85d0*two*rnorm
b = 0.85d0*two*rnorm
else if (rnorm .ge. half .and. rnorm.lt.white) then
r = 0.85d0*two*(one - rnorm)
g = 0.85d0*two*(one - rnorm)
b = 0.85d0*two*(one - rnorm)
else if (rnorm .ge. white ) then
r = zero
g = zero
b = zero
end if
!
end subroutine s_colormap_sym_grayscale
!
! ----------------------------------------------------------------------
!
end module colormap_grayscales
63 changes: 63 additions & 0 deletions src/Fortran_libraries/VIZ_src/volume_rendering/colormap_metal.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
!>@file colormap_metal.F90
!!@brief module colormap_metal
!!
!!@author H. Matsui
!!@date Programmed in Apr., 2024
!
!>@brief Colormapping for molten metal
!!
!!@verbatim
!! subroutine s_colormap_metal(rnorm, r, g, b)
!! real(kind = kreal), intent(in) :: rnorm
!! real(kind = kreal), intent(inout) :: r, g, b
!!@endverbatim
!
module colormap_metal
!
use m_precision
use m_constants
!
implicit none
!
! ------------------------------------------------------------------
!
contains
!
! ------------------------------------------------------------------
!
subroutine s_colormap_metal(rnorm, r, g, b)
!
real(kind = kreal), intent(in) :: rnorm
real(kind = kreal), intent(inout) :: r, g, b
!
real(kind = kreal), parameter :: c_g1 = 0.6
real(kind = kreal), parameter :: r_mul = one / c_g1
real(kind = kreal), parameter :: g_mul = one / (one - c_g1)
!
real(kind = kreal) :: x
!
!
x = rnorm
if (x .lt. zero) then
r = zero
else if(r .lt. c_g1) then
r = x * r_mul
else
r = one
end if
!
if (x .lt. c_g1) then
g = zero
else if(r .lt. one) then
g = (x - c_g1) * g_mul
else
g = one
end if
!
b = zero
!
end subroutine s_colormap_metal
!
! ----------------------------------------------------------------------
!
end module colormap_metal
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
!>@file colormap_rainbow.F90
!!@brief module colormap_rainbow
!!
!!@author H. Matsui
!!@date Programmed in Apr., 2024
!
!>@brief Rainbow colormapping
!!
!!@verbatim
!! subroutine s_colormap_rainbow(rnorm, r, g, b)
!! real(kind = kreal), intent(in) :: rnorm
!! real(kind = kreal), intent(inout) :: r, g, b
!!@endverbatim
!
module colormap_rainbow
!
use m_precision
use m_constants
!
implicit none
!
! ------------------------------------------------------------------
!
contains
!
! ------------------------------------------------------------------
!
subroutine s_colormap_rainbow(rnorm, r, g, b)
!
real(kind = kreal), intent(in) :: rnorm
real(kind = kreal), intent(inout) :: r, g, b
!
real(kind = kreal), parameter :: purple = zero
real(kind = kreal), parameter :: blue = 0.1e0
real(kind = kreal), parameter :: ocean = 0.325e0
real(kind = kreal), parameter :: green = 0.55e0
real(kind = kreal), parameter :: yellow = 0.775e0
real(kind = kreal), parameter :: red = one
real(kind = kreal), parameter :: forty = four*ten
!
!
if (rnorm .lt. purple ) then
r = half
g = zero
b = one
else if (rnorm .ge. purple .and. rnorm.lt.blue) then
r = half - five*rnorm
g = zero
b = one
else if (rnorm .ge. blue .and. rnorm.lt.ocean) then
r = zero
g = forty*(rnorm-blue) / dnine
b = one
else if (rnorm .ge. ocean .and. rnorm.lt.green) then
r = zero
g = one
b = one - forty*(rnorm-ocean) / dnine
else if (rnorm .ge. green .and. rnorm.lt.yellow) then
r = forty*(rnorm-green) / dnine
g = one
b = zero
else if (rnorm .ge. yellow .and. rnorm.lt. red) then
r = one
g = one - forty*(rnorm-yellow) / dnine
b = zero
else if (rnorm .ge. red ) then
r = one
g = zero
b = zero
end if
!
end subroutine s_colormap_rainbow
!
! ----------------------------------------------------------------------
!
end module colormap_rainbow
117 changes: 117 additions & 0 deletions src/Fortran_libraries/VIZ_src/volume_rendering/colormap_space.f90
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
!>@file colormap_space.F90
!!@brief module colormap_space
!!
!!@author H. Matsui
!!@date Programmed in Apr., 2024
!
!>@brief Colormapping
!!
!!@verbatim
!! subroutine s_colormap_space(rnorm, r, g, b)
!! real(kind = kreal), intent(in) :: rnorm
!! real(kind = kreal), intent(inout) :: r, g, b
!!@endverbatim
!
module colormap_space
!
use m_precision
use m_constants
!
implicit none
!
! ------------------------------------------------------------------
!
contains
!
! ------------------------------------------------------------------
!
subroutine s_colormap_space(rnorm, r, g, b)
!
real(kind = kreal), intent(in) :: rnorm
real(kind = kreal), intent(inout) :: r, g, b
!
real(kind = kreal), parameter :: c_r1 = 37067.0 / 158860.0
real(kind = kreal), parameter :: c_r2 = 85181.0 / 230350.0
real(kind = kreal), parameter &
& :: c_r3 = (sqrt(3196965649.0) + 83129.0) / 310480.0
real(kind = kreal), parameter :: c_r4 = 231408.0 / 362695.0
real(kind = kreal), parameter :: c_r5 = 152073.0 / 222340.0
real(kind = kreal), parameter :: c_r6 = 294791.0 / 397780.0
real(kind = kreal), parameter :: c_r7 = 491189.0 / 550980.0
!
real(kind = kreal), parameter &
& :: c_g1 = (-sqrt(166317494.0) + 39104.0) / 183830.0
real(kind = kreal), parameter &
& :: c_g3 = (3.0 * sqrt(220297369.0) + 58535.0) / 155240.0
!
real(kind = kreal), parameter :: c_b1 = 51987.0 / 349730.0
!
real(kind = kreal) :: x, xx
!
!
x = rnorm
if (x .lt. c_r1) then
r = 0.0
else if (x .lt. c_r2) then
xx = x - c_r1
r = (780.25 * xx + 319.71) * xx / 255.0
else if (x .lt. c_r3) then
r = ((1035.33580904442 * x - 82.5380748768798) * x &
& - 52.8985266363332) / 255.0
else if (x .lt. c_r4) then
r = (339.41 * x - 33.194) / 255.0
else if (x .lt. c_r5) then
r = (1064.8 * x - 496.01) / 255.0
else if (x .lt. c_r6) then
r = (397.78 * x - 39.791) / 255.0
else if (x .lt. c_r7) then
r = 1.0
else if (x .lt. one) then
r = (5509.8 * x + 597.91) * x / 255.0
else
r = 1.0
end if

if (x .lt. zero) then
g = 0.0
else if (x .lt. c_g1) then
g = (-1838.3 * x + 464.36) * x / 255.0
else if (x .lt. c_r1) then
g = (-317.72 * x + 74.134) / 255.0
else if (x .lt. c_g3) then
g = 0.0
else if (x .lt. c_r6) then
xx = x - c_g3
g = (-1945.0 * xx + 1430.2) * xx / 255.0
else if (x .lt. c_r7) then
g = ((-1770.0 * x + 3.92813840044638e3) * x &
& - 1.84017494792245e3) / 255.0
else
g = 1.0
end if

if (x .lt. zero) then
b = 0.0
else if (x .lt. c_b1) then
b = (458.79 * x) / 255.0
else if (x .lt. c_r2) then
b = (109.06 * x + 51.987) / 255.0
else if (x .lt. c_r3) then
b = (339.41 * x - 33.194) / 255.0
else if (x .lt. c_g3) then
b = ((-1552.4 * x + 1170.7) * x - 92.996) / 255.0
else if (x .lt. 27568.0 / 38629.0) then
b = 0.0
else if (x .lt. 81692.0 / 96241.0) then
b = (386.29 * x - 275.68) / 255.0
else if (x .lt. 1.0) then
b = (1348.7 * x - 1092.6) / 255.0
else
b = 1.0
end if
!
end subroutine s_colormap_space
!
! ----------------------------------------------------------------------
!
end module colormap_space
Loading

0 comments on commit b5c71a9

Please sign in to comment.