Ejemplo n.º 1
0
            size = [img.getReadXSize(), img.getReadYSize()]
            foundSize = True
        imgs[i] = img
    else:
        # assume it is a constant value
        val = float(fImg.getFullpath())
        if is_sRGB:
            print("Converting", getChannelName(i), "to linear")
            # Convert to linear
            val = math.pow(val, 2.2)
        imgs[i] = val

print("Size:", size)

output = PNMImage(*size)
output.setNumChannels(4)
output.setColorType(PNMImageHeader.CTFourChannel)
output.fill(1.0, 0.0, 0.0)
output.alphaFill(1.0)

for channel, img in imgs.items():
    img
    print("Filling in", getChannelName(channel), "channel...")
    if isinstance(img, float):
        print("Value", img)
    for x in range(size[0]):
        for y in range(size[1]):
            if isinstance(img, float):
                setChannel(output, x, y, channel, img)
            else:
                setChannel(output, x, y, channel, getChannel(img, x, y, 0))
Ejemplo n.º 2
0
    if channel == CHANNEL_AO:
        return img.getRed(x, y)
    elif channel == CHANNEL_ROUGHNESS:
        return img.getGreen(x, y)
    elif channel == CHANNEL_METALLIC:
        return img.getBlue(x, y)
    elif channel == CHANNEL_EMISSIVE:
        return img.getAlpha(x, y)


armeFile = raw_input("ARME file: ")
armeFilename = Filename.fromOsSpecific(armeFile)

img = PNMImage()
img.read(armeFilename)

for i in range(4):
    name = getChannelName(i).lower()
    print("Writing", name)
    chImg = PNMImage(img.getReadXSize(), img.getReadYSize())
    chImg.setNumChannels(1)
    chImg.setColorType(PNMImageHeader.CTGrayscale)
    for x in range(img.getReadXSize()):
        for y in range(img.getReadYSize()):
            val = getChannel(img, x, y, i)
            chImg.setXel(x, y, val)
    chImg.write(
        Filename(armeFilename.getFullpathWoExtension() + "_" + name + ".png"))

print("Done")