Open SikangSHU opened 2 years ago
Hello! I need to input the number of
Colour
from the command line. How can I usesys.argv
and not change the format of the file? When I write the program as follows,Colour
can't be editted.gray1_1D = gray1[0] filename = f"CD8.tif[tile,pyramid,subifd]" print(f"writing {filename} ...") col1 = int(sys.argv[1]) print(col1) CD8 = (255 - gray1_1D * 255).cast("int").colourspace("grey16") CD8.set_type(pyvips.GValue.gstr_type, "image-description", f""" <OME xmlns="http://www.openmicroscopy.org/Schemas/OME/2016-06" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Creator="OME Bio-Formats 6.7.0" xsi:schemaLocation="http://www.openmicroscopy.org/Schemas/OME/2016-06 http://www.openmicroscopy.org/Schemas/OME/2016-06/ome.xsd"> <Image ID="Image:0"> <!-- Minimum required fields about image dimensions --> <Pixels DimensionOrder="XYCZT" ID="Pixels:0" Interleaved="false" SizeC="1" SizeT="1" SizeX="66607" SizeY="53298" SizeZ="1" Type="uint16"> <Channel Color=col1 ID="Channel:0:0" Name="Channel 1" SamplesPerPixel="1"><LightPath/></Channel><TiffData FirstC="0" FirstT="0" FirstZ="0" IFD="0" PlaneCount="1"> </TiffData> </Pixels> </Image> </OME> """) CD8.tiffsave('E:\\CD8.tif', tile=True, pyramid=True, subifd=True)
(learn) C:\Users>python E:/Learning/3c_pyvips.py -16718848
Oh, sorry. I missed a space. I haved solved the problem. Thank you!
gray1_1D = gray1[0]
filename = f"CD8.tif[tile,pyramid,subifd]"
print(f"writing {filename} ...")
print(sys.argv[1])
colour1 = sys.argv[1]
CD8 = (255 - gray1_1D * 255).cast("int").colourspace("grey16")
CD8.set_type(pyvips.GValue.gstr_type, "image-description",
f"""
<OME xmlns="http://www.openmicroscopy.org/Schemas/OME/2016-06"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
Creator="OME Bio-Formats 6.7.0"
xsi:schemaLocation="http://www.openmicroscopy.org/Schemas/OME/2016-06
http://www.openmicroscopy.org/Schemas/OME/2016-06/ome.xsd">
<Image ID="Image:0">
<!-- Minimum required fields about image dimensions -->
<Pixels DimensionOrder="XYCZT"
ID="Pixels:0"
Interleaved="false"
SizeC="1"
SizeT="1"
SizeX="66607"
SizeY="53298"
SizeZ="1"
Type="uint16">
<Channel Color="-"""+str(colour1)+"""" ID="Channel:0:0" Name="Channel 1" SamplesPerPixel="1"><LightPath/></Channel><TiffData FirstC="0" FirstT="0" FirstZ="0" IFD="0" PlaneCount="1">
</TiffData>
</Pixels>
</Image>
</OME>
""")
CD8.tiffsave('E:\\CD82.tif', tile=True, pyramid=True, subifd=True)
Dear Professor: I consider to save images to tif, but there is an error occured as follows. I don't know how to save. I would greatly appreciate it if you could help me. This is my code: