Package ca.eandb.jmist.framework.color

Examples of ca.eandb.jmist.framework.color.ColorModel


      e.printStackTrace();
      return;
    }
    DxfReader dxf = new AsciiDxfReader(fr);
    DxfSceneBuilder builder = new DxfSceneBuilder();
    ColorModel cm = RGBColorModel.getInstance();
    SceneElement elem = builder.createScene(cm, dxf);
    System.out.println(elem.toString());
  }
View Full Code Here


    int      w    = raster.getWidth();
    int      h    = raster.getHeight();
    int      x    = MathUtil.clamp((int) Math.floor(u * (double) w), 0, w - 1);
    int      y    = MathUtil.clamp((int) Math.floor(v * (double) h), 0, h - 1);
    double[]  pixel  = raster.getPixel(x, y, placeholder.get());
    ColorModel  cm    = lambda.getColorModel();

    placeholder.set(pixel);

    if (factory != null) {
      return cm.getContinuous(factory.createSpectrum(pixel)).sample(lambda);
    } else {
      switch (pixel.length) {
      case 1:
        return cm.getGray(pixel[0], lambda);
      case 3:
        return cm.fromRGB(pixel[0]/255.0, pixel[1]/255.0, pixel[2]/255.0).sample(lambda);
      case 4:
      {
        double alpha = pixel[3] / 255.0;
        if (MathUtil.equal(alpha, 1.0)) {
          return cm.fromRGB(pixel[0]/255.0, pixel[1]/255.0, pixel[2]/255.0).sample(lambda);
        } else if (MathUtil.equal(alpha, 0.0)) {
          return background.evaluate(p, lambda);
        } else {
          Color bg = background.evaluate(p, lambda);
          Color fg = cm.fromRGB(pixel[0]/255.0, pixel[1]/255.0, pixel[2]/255.0).sample(lambda);
          return fg.times(alpha).plus(bg.times(1.0 - alpha));
        }
      }
      default:
        throw new RuntimeException("Raster has unrecognized number of bands.");
View Full Code Here

   */
  @Override
  public Vector3 scatter(final SurfacePointGeometry x, Vector3 v, boolean adjoint,
      double wavelength, Random rnd) {

    ColorModel cm = new MonochromeColorModel(wavelength);
    Color white = cm.sample(rnd);
    SurfacePoint surf = new SurfacePoint() {
      public Medium getAmbientMedium() {
        return ambientMedium;
      }
      public Material getMaterial() {
View Full Code Here

  public BioSpecMaterial(ColorModel colorModel) {
    this.colorModel = colorModel;
  }

  private void build() {
    ColorModel cm = colorModel;

    subsurface = new LayeredMaterial()
      .addLayerToBottom( // air / stratum corneum interface
        new TrowbridgeReitzMaterial(foldsAspectRatio, IOR_STRATUM_CORNEUM, 1.0))
      .addLayerToBottom( // stratum corneum
        new SequentialMaterial()
          .addScatterer(new TabularPerturbingMaterial(exitant_angles, stratum_corneum_546, 1000))
          .addScatterer(new AbsorbingMaterial(
            cm.getContinuous(new ScaledFunction1(
              concentrationBetaCaroteneInStratumCorneum / 537.0,
              OMLC_PRAHL_BETACAROTENE)),
            thicknessStratumCorneum)))
      .addLayerToBottom( // stratum corneum / epidermis interface
        new FresnelMaterial(IOR_EPIDERMIS, IOR_STRATUM_CORNEUM))
      .addLayerToBottom( // epidermis
        new SequentialMaterial()
          .addScatterer(new TabularPerturbingMaterial(exitant_angles, epidermis_546, 1000))
          .addScatterer(new AbsorbingMaterial(
            cm.getContinuous(new SumFunction1()
              .addChild(new ScaledFunction1(
                pctMelanosomesInEpidermis * concentrationEumelanin,
                OMLC_EUMELANIN_EXT_MGML))
              .addChild(new ScaledFunction1(
                pctMelanosomesInEpidermis * concentrationPheomelanin,
                OMLC_PHEOMELANIN_EXT_MGML))
              .addChild(new ScaledFunction1(
                (1.0 - pctMelanosomesInEpidermis) * concentrationBetaCaroteneInEpidermis / 537.0,
                OMLC_PRAHL_BETACAROTENE))),
            thicknessEpidermis)))
      .addLayerToBottom( // epidermis / papillary dermis interface
        new FresnelMaterial(IOR_PAPILLARY_DERMIS, IOR_EPIDERMIS))
      .addLayerToBottom( // papillary dermis
        new SequentialMaterial()
          .addScatterer(new DiffusingMaterial())
          .addScatterer(new AbsorbingMaterial(
            cm.getContinuous(new SumFunction1()
              .addChild(new ScaledFunction1(
                pctWholeBloodInPapillaryDermis * concentrationHemoglobinInBlood * ratioOxyDeoxyHemoglobin / 66500.0,
                OMLC_PRAHL_OXYHEMOGLOBIN))
              .addChild(new ScaledFunction1(
                pctWholeBloodInPapillaryDermis * concentrationHemoglobinInBlood * (1.0 - ratioOxyDeoxyHemoglobin) / 66500.0,
                OMLC_PRAHL_DEOXYHEMOGLOBIN))
              .addChild(new ScaledFunction1(
                pctWholeBloodInPapillaryDermis * concentrationBetaCaroteneInBlood / 537.0,
                OMLC_PRAHL_BETACAROTENE))
              .addChild(new ScaledFunction1(
                pctWholeBloodInPapillaryDermis * concentrationBilirubinInBlood / 585.0,
                OMLC_PRAHL_BILIRUBIN))),
            thicknessPapillaryDermis)))
      .addLayerToBottom( // papillary dermis / reticular dermis interface
        new FresnelMaterial(IOR_RETICULAR_DERMIS, IOR_PAPILLARY_DERMIS))
      .addLayerToBottom( // reticular dermis
        new SequentialMaterial()
          .addScatterer(new DiffusingMaterial())
          .addScatterer(new AbsorbingMaterial(
            cm.getContinuous(new SumFunction1()
              .addChild(new ScaledFunction1(
                pctWholeBloodInReticularDermis * concentrationHemoglobinInBlood * ratioOxyDeoxyHemoglobin / 66500.0,
                OMLC_PRAHL_OXYHEMOGLOBIN))
              .addChild(new ScaledFunction1(
                pctWholeBloodInReticularDermis * concentrationHemoglobinInBlood * (1.0 - ratioOxyDeoxyHemoglobin) / 66500.0,
                OMLC_PRAHL_DEOXYHEMOGLOBIN))
              .addChild(new ScaledFunction1(
                pctWholeBloodInReticularDermis * concentrationBetaCaroteneInBlood / 537.0,
                OMLC_PRAHL_BETACAROTENE))
              .addChild(new ScaledFunction1(
                pctWholeBloodInReticularDermis * concentrationBilirubinInBlood / 585.0,
                OMLC_PRAHL_BILIRUBIN))),
            thicknessReticularDermis)))
      .addLayerToBottom( // reticular dermis / hypodermis interface
        new LambertianMaterial(cm.getWhite()));
  }
View Full Code Here

  /**
   * Populates the <code>LayeredMaterial</code> according to the ABM
   * model from the model parameters.
   */
  private synchronized void build() {
    ColorModel cm = colorModel;
    subsurface.clear();

//    Function1 iorMesophyll = new AXpBFunction1(
//        (1.0 - scattererFractionInMesophyll),
//        1.5608 * scattererFractionInMesophyll,
//        IOR_WATER);

    double iorMesophyll = 1.415;

    double iorAntidermalWall = (1.0 - scattererFractionInAntidermalWall)
        * MathUtil.mean(IOR_WATER_VALUES) + 1.535
        * scattererFractionInAntidermalWall;

    double concDryMatter = dryBulkDensity / (1.0 - airVolumeFraction);

    double concProtein = concDryMatter * proteinFraction;
    double concCellulose = concDryMatter * celluloseFraction;
    double concLignin = concDryMatter * ligninFraction;

    double absProtein = concProtein * SAC_PROTEIN;
    double absCellulose = concCellulose * SAC_CELLULOSE_LIGNIN;
    double absLignin = concLignin * SAC_CELLULOSE_LIGNIN;

    Function1 mesophyllAbsorptionCoefficient = new SumFunction1()
      .addChild(new ScaledFunction1(
          concChlorophyllAInMesophyll + concChlorophyllBInMesophyll,
          SAC_CHLOROPHYLL_AB))
      .addChild(new ScaledFunction1(
          concCarotenoidsInMesophyll,
          SAC_CAROTENOIDS))
      .addChild(new ConstantFunction1(absProtein + absCellulose + absLignin))
      .addChild(SAC_WATER);

//    try {
//      OutputStream file = new FileOutputStream("/Users/brad/mesosac.csv");
//      PrintStream out = new PrintStream(new CompositeOutputStream()
//          .addChild(System.out)
//          .addChild(file));
//      for (int i = 400; i <= 700; i += 5) {
//        out.println(mesophyllAbsorptionCoefficient.evaluate(1e-9 * (double) i));
//      }
//      out.flush();
//      file.close();
//    } catch (IOException e) {
//      e.printStackTrace();
//    }

    double mesophyllFraction = bifacial ? 0.5 : 0.8;
    mesophyllThickness = mesophyllFraction * wholeLeafThickness;

    double lambda = 550e-9;
    System.out.printf("mesophyllAbsorptionCoefficient=%f", mesophyllAbsorptionCoefficient.evaluate(lambda));
    System.out.println();
    System.out.printf("mesophyllThickness=%f", mesophyllThickness);
    System.out.println();
    System.out.printf("mesophyllOpticalDepth=%f", mesophyllAbsorptionCoefficient.evaluate(lambda) * mesophyllThickness);
    System.out.println();
    System.out.printf("nCuticle=%f", IOR_CUTICLE.evaluate(lambda));
    System.out.println();
    System.out.printf("nWater=%f", IOR_WATER.evaluate(lambda));
    System.out.println();
    System.out.printf("sacWater=%f", SAC_WATER.evaluate(lambda));
    System.out.println();
    System.out.printf("nWall=%f", iorAntidermalWall);
    System.out.println();
    System.out.printf("nMesophyll=%f", iorMesophyll);
    System.out.println();
    System.out.printf("dryBulkDensity=%f", dryBulkDensity);
    System.out.println();

    double iorCuticle = MathUtil.mean(IOR_CUTICLE_VALUES);
    double iorWater = MathUtil.mean(IOR_WATER_VALUES);

    if (bifacial) {
      subsurface
        .addLayerToBottom(new ABMInterfaceMaterial(
            iorCuticle, 1.0,
            cuticleUndulationsAspectRatio,
            epidermisCellCapsAspectRatio,
            Double.POSITIVE_INFINITY,
            epidermisCellCapsAspectRatio))
        .addLayerToBottom(new ABMInterfaceMaterial(
            iorMesophyll, iorCuticle,
            epidermisCellCapsAspectRatio,
            palisadeCellCapsAspectRatio,
            epidermisCellCapsAspectRatio,
            palisadeCellCapsAspectRatio))
        .addLayerToBottom(new ABMSieveAbsorbingMaterial(
            cm.getContinuous(mesophyllAbsorptionCoefficient),
            mesophyllThickness))
        .addLayerToBottom(new ABMInterfaceMaterial(
            1.0, iorMesophyll,
            palisadeCellCapsAspectRatio,
            spongyCellCapsAspectRatio,
            palisadeCellCapsAspectRatio,
            spongyCellCapsAspectRatio))
        .addLayerToBottom(new ABMInterfaceMaterial(
            iorAntidermalWall, 1.0,
            Double.POSITIVE_INFINITY,
            Double.POSITIVE_INFINITY,
            Double.POSITIVE_INFINITY,
            Double.POSITIVE_INFINITY))
        .addLayerToBottom(new ABMInterfaceMaterial(
            iorCuticle, iorAntidermalWall,
            Double.POSITIVE_INFINITY,
            epidermisCellCapsAspectRatio,
            Double.POSITIVE_INFINITY,
            epidermisCellCapsAspectRatio))
        .addLayerToBottom(new ABMInterfaceMaterial(
            1.0, iorCuticle,
            epidermisCellCapsAspectRatio,
            Double.POSITIVE_INFINITY,
            epidermisCellCapsAspectRatio,
            cuticleUndulationsAspectRatio));
    } else { // unifacial
      topSpongyMesophyllLayer = new VariableThicknessAbsorbingMaterial(
          cm.getContinuous(mesophyllAbsorptionCoefficient));
      bottomSpongyMesophyllLayer = new VariableThicknessAbsorbingMaterial(
          cm.getContinuous(mesophyllAbsorptionCoefficient));
      subsurface
        .addLayerToBottom(new ABMInterfaceMaterial(
            iorCuticle, 1.0,
            cuticleUndulationsAspectRatio,  // \/
            epidermisCellCapsAspectRatio,   // \
View Full Code Here

      pixel = ColorUtil.add(pixel, ColorUtil.div(ColorUtil.sub(sample, pixel), i + 1));
      s = ColorUtil.add(s, ColorUtil.mul(ColorUtil.sub(sample, oldPixel), ColorUtil.sub(sample, pixel)));
    }

    if (testMode) {
      ColorModel cm = pixel.getColorModel();
      double value = (double) (i - minSamples) / (double) (maxSamples - minSamples);
      return cm.getGray(value, pixel.getWavelengthPacket());
    } else {
      return pixel;
    }
  }
View Full Code Here

TOP

Related Classes of ca.eandb.jmist.framework.color.ColorModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.