Open yaqwsx opened 4 years ago
If I understand correctly you want to create a new cbddlp file with anti-aliasing from a single image? This does not work. The library expects that you supply an image / sublayer for each level of anti-aliasing that you want. For example anti-aliasing with level two expects two images / two sublayers. Those will then sequentially cured by the printer but at the same layer height. If I am correct, I would suggest that you generate a AA file with chitubox und export the images with pyphotonfile and have a look how they are arranged. If I am mistaken, please let me know.
This is what I do: I take a grayscale image and generate n images by thresholding the grayscale image:
[imageToRle(layerImage.point(lambda x: threshold(i / aaLevel, x)))
for i in range(aaLevel)])
This is not the correct approach?
I expect these images to be subsequently shown on the same height. But it is not what I observe (only the first one is shown for the whole time).
yes that is one way to do it. there was a bug with the library that was recently fixed that did not allowed the correct writing of sublayers. maybe that was your case.
download the latest update and try again
No dia domingo, 19 de janeiro de 2020, Jan Mrázek notifications@github.com escreveu:
This is what I do: I take a grayscale image and generate n images by thresholding the grayscale image:
[imageToRle(layerImage.point(lambda x: threshold(i / aaLevel, x))) for i in range(aaLevel)])
This is not the correct approach?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/fookatchu/pyphotonfile/issues/11?email_source=notifications&email_token=ACUR56QW652UVQGEHK5HUTDQ6RM4ZA5CNFSM4KFZWRE2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEJKS76A#issuecomment-576008184, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACUR56SCYBXFRVDDBFW5VL3Q6RM4ZANCNFSM4KFZWREQ .
-- Com os melhores cumprimentos, Vinicius Silva
I am aware of the bug (as I reported it when I was troubleshooting this issue). Even after the bug was fixed, the problem is preserved. Or does the sliced file produce expected results on your printers?
oh sorry :) didn't register it had been you.
do you have a sample of the code you are using to implement the grey to mono layer injection?
and what exactly is the result on your Mars? it should work the same for sny CBD-tech board printer
No dia segunda-feira, 20 de janeiro de 2020, Jan Mrázek < notifications@github.com> escreveu:
I am aware of the bug (as I reported it when I was troubleshooting it). Even after the bug was fixed, the problem is preserved. Or does the sliced file produce expected results on your printers?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/fookatchu/pyphotonfile/issues/11?email_source=notifications&email_token=ACUR56QIHVCAO3IM24GTVQ3Q6VYRFA5CNFSM4KFZWRE2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEJMBCOI#issuecomment-576196921, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACUR56XCXOOYXTIYCCIEWHTQ6VYRFANCNFSM4KFZWREQ .
-- Com os melhores cumprimentos, Vinicius Silva
also have you tried disassembling a known working sliced file to compare and reassembling it to make sure it is not a issue with the library?
No dia segunda-feira, 20 de janeiro de 2020, Vinicius Silva < x3msnake@gmail.com> escreveu:
oh sorry :) didn't register it had been you.
do you have a sample of the code you are using to implement the grey to mono layer injection?
and what exactly is the result on your Mars? it should work the same for sny CBD-tech board printer
No dia segunda-feira, 20 de janeiro de 2020, Jan Mrázek < notifications@github.com> escreveu:
I am aware of the bug (as I reported it when I was troubleshooting it). Even after the bug was fixed, the problem is preserved. Or does the sliced file produce expected results on your printers?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/fookatchu/pyphotonfile/issues/11?email_source=notifications&email_token=ACUR56QIHVCAO3IM24GTVQ3Q6VYRFA5CNFSM4KFZWRE2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEJMBCOI#issuecomment-576196921, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACUR56XCXOOYXTIYCCIEWHTQ6VYRFANCNFSM4KFZWREQ .
-- Com os melhores cumprimentos, Vinicius Silva
-- Com os melhores cumprimentos, Vinicius Silva
The problem with reassembling the file is that I get only a slightly different sublayer from the slicer, which I am not able to detect by eye when run on a printer (and I probably have no other method to detect if the multisampling still works).
The whole code is in the initial issue message, the only missing functions are:
def imageToRle(image):
return imgarr_to_rle(np.array(image))
def threshold(level, pixel):
# Turn on the dim pixel at the last
if pixel >= (1 - level) * 255:
return 255
return 0
I have verified that the thresholding works as expecting (by saving each sublayer to an image file).
use true different image's on reimport
like a number changing as each layer goes
1-1, 1-2... 2-1, 2-2...
No dia segunda-feira, 20 de janeiro de 2020, Jan Mrázek < notifications@github.com> escreveu:
The problem with reassembling the file is that I get only a slightly different sublayer from the slicer, which I am not able to detect by eye when run on a printer (and I probably have no other method to detect if the multisampling still works).
The whole code is in the initial issue message, the only missing functions are:
def imageToRle(image): return imgarr_to_rle(np.array(image)) def threshold(level, pixel):
Turn on the dim pixel at the last
if pixel >= (1 - level) * 255: return 255 return 0
I have verified that the thresholding works as expecting (by saving each sublayer to an image file).
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/fookatchu/pyphotonfile/issues/11?email_source=notifications&email_token=ACUR56SHO3BPKG2L4RXMQDDQ6V2I3A5CNFSM4KFZWRE2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEJMCQRI#issuecomment-576202821, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACUR56TKJYRGKPJVRBBNW5TQ6V2I3ANCNFSM4KFZWREQ .
-- Com os melhores cumprimentos, Vinicius Silva
I tried your suggestion - to get a working file from the slicer and just to rewrite the images. I also tried to generate an AA file from scratch; below is my code:
def testPattern(i, aaLevel):
x = np.linspace(0, 255, 2560)
image = np.tile(x, (1440, 1)).T
image[image >= (1 - (i + 1) / 8) * 255] = 255
image[image != 255] = 0
return image
def testAA():
mars = Photon("AAExample.cbddlp")
print("layer_levels: {}".format(mars.layer_levels))
print("anti_aliasing_level: {}".format(mars.anti_aliasing_level))
for i in range(len(mars.layers)):
print("Layer")
for sublayerId, sublayer in enumerate(mars.layers[i].sublayers):
image = testPattern(sublayerId, 8)
sublayer._data = imgarr_to_rle(image)
mars.write("test.cbddlp")
def genAA():
mars = Photon()
mars.layer_levels = mars.anti_aliasing_level = 8
mars.exposure_time = float(10)
mars.exposure_time_bottom = float(10)
mars.layer_height = float(0.05)
mars.bottom_layers = int(10)
for i in range(10):
print("Layer")
mars.append_layer(
[imgarr_to_rle(testPattern(j, 8)) for j in range(8)])
mars.write("gen.cbddlp")
The produced files are in the attachment. slicedFiles.zip
The rewritten file worked as expected; the generated one did not. What am I doing wrong?
I would look into the image format, maybe you are using the wrong type 24bit vs Greyscale or vice versa, I would compare a working image and one of your images for other encoding differences like compression type colour palette, colour depth...
Jan Mrázek notifications@github.com escreveu no dia quinta, 23/01/2020 à(s) 19:58:
I tried your suggestion - to get a working file from the slicer and just to rewrite the images. I also tried to generate an AA file from scratch; below is my code:
def testPattern(i, aaLevel): x = np.linspace(0, 255, 2560) image = np.tile(x, (1440, 1)).T image[image >= (1 - (i + 1) / 8) * 255] = 255 image[image != 255] = 0 return image def testAA(): mars = Photon("AAExample.cbddlp") print("layer_levels: {}".format(mars.layer_levels)) print("anti_aliasing_level: {}".format(mars.anti_aliasing_level)) for i in range(len(mars.layers)): print("Layer") for sublayerId, sublayer in enumerate(mars.layers[i].sublayers): image = testPattern(sublayerId, 8) sublayer._data = imgarr_to_rle(image) mars.write("test.cbddlp") def genAA(): mars = Photon() mars.layer_levels = mars.anti_aliasing_level = 8 mars.exposure_time = float(10) mars.exposure_time_bottom = float(10) mars.layer_height = float(0.05) mars.bottom_layers = int(10) for i in range(10): print("Layer") mars.append_layer( [imgarr_to_rle(testPattern(j, 8)) for j in range(8)]) mars.write("gen.cbddlp")
The produced files are in the attachment. slicedFiles.zip https://github.com/fookatchu/pyphotonfile/files/4105189/slicedFiles.zip
The rewritten file worked as expected; the generated one did not. What am I doing wrong?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/fookatchu/pyphotonfile/issues/11?email_source=notifications&email_token=ACUR56VEOPEWUWPRBEZPNYDQ7HZG5A5CNFSM4KFZWRE2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEJYUPVI#issuecomment-577849301, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACUR56XC57COUDRZMEZBR63Q7HZG5ANCNFSM4KFZWREQ .
-- Com os melhores cumprimentos, Vinicius Silva
The code above generates the image, so there cannot be a difference. I think the problem is with the setup of the empty file; If I change
mars = Photon()
to
mars = Photon("AAExample.cbddlp")
mars.delete_layers()
and append layers, I get the correct result.
Also, the next thing I noted is that mars.layer_levels = mars.anti_aliasing_level = 8
has no effect - the number of sublayers stays the same in the output file. This would explain why I wasn't able to get antialiasing working with the original code - the antialiasing level was still one.
The 'empty file' falls back to a .photon-file which I generated for the v1 format, as I was not able to generate a new file from scratch due to limited knowledge of the fileformat. I think this is most likely the source of the problem. I will make a new file for the v2 format or generate a new file from scratch, which would be better for building packages. In the meantime, you can use your own file and just delete all layers before adding new ones.
Thank you for the response. I understand the problem with the initial file. However, I was wondering, do you have any idea why changing the anti-aliasing level does not work? I would like to be able to change it. Having several pre-generated files with AA level could work, but I am aiming to experiment with AA levels which ChiTuBox refuses to produce (I guess it is due to the limitation of the drop-down form and I would like to test if the printer can handle non-standard AA level).
Could you point me to materials about the file format you used during the development?
Currently I do not know why this doesn't work, but I have to have a look at your code and get into my write
-method again. I will try to produce a working example in the next days on how to generate a new AA-file from scratch. Theoretically it should work but I mostly tested the library with pregenerated files, and not with 'from scratch' generation.
For the fileformat reference I used mostly CBDDLPinfo as a reference.
that was what i was suggesting next. this is probably related to the issues i am having too
No dia sexta-feira, 24 de janeiro de 2020, Heiko notifications@github.com escreveu:
The 'empty file' falls back to a .photon-file which I generated for the v1 format, as I was not able to generate a new file from scratch due to limited knowledge of the fileformat. I think this is most likely the source of the problem. I will make a new file for the v2 format or generate a new file from scratch, which would be better for building packages. In the meantime, you can use your own file and just delete all layers before adding new ones.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/fookatchu/pyphotonfile/issues/11?email_source=notifications&email_token=ACUR56RPSKZ4FWO5JOY3X2DQ7KWS3A5CNFSM4KFZWRE2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEJ2FWQQ#issuecomment-578050882, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACUR56WTTTAGIRJANL6UEELQ7KWS3ANCNFSM4KFZWREQ .
-- Com os melhores cumprimentos, Vinicius Silva
https://github.com/Photonsters/anycubic-photon-docs/blob/dev/Temp-resources/ExpTestCreatorAA.zip
Maybe this file will help. it was made by @cex123 same as the cbddlpinfo by my request when i was trying to investigate AA on photon.
the code there might shed some light
Excuse a potential thread hyjack; but I am also looking into writing valid photon AA files, and I want to check part of my understanding.
In the implementation of tresholding as discussed here, each sublayer has the same exposure time; so 8 AA levels means 8 distict levels of exposure.
Is it also possible to have 8 sublayers, each with its own exposure time? If we had 8 exposures, the i-th of which had base*2**i exposure time, and each subimage would simply be the 8-bit grayscale image with a bitmask applied, we should be able to realize the full 256 bit depth of exposure times. Or use just 4 images to get 16 different values, etc.
After I wrote this, I noticed the comment '# currently ignored by firmware?' wrt per sublayer exposure time; so I suppose this is not going to fly...
no that is not possible. the way this works is divide the total exposure for the layer by the number of sublayers
this AA method will never be as good as real greyscale
No dia domingo, 2 de fevereiro de 2020, Eelco Hoogendoorn < notifications@github.com> escreveu:
Excuse a potential thread hyjack; but I am also looking into writing valid photon AA files, and I want to check part of my understanding.
In the implementation of tresholding as discussed here, each sublayer has the same exposure time; so 8 AA levels means 8 distict levels of exposure.
Is it also possible to have 8 sublayers, each with its own exposure time? If we had 8 exposures, the i-th of which had base*2**i exposure time, and each subimage would simply be the 8-bit grayscale image with a bitmask applied, we should be able to realize the full 256 bit depth of exposure times. Or use just 4 images to get 16 different values, etc.
After I wrote this, I noticed the comment '# currently ignored by firmware?' wrt per sublayer exposure time; so I suppose this is not going to fly...
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/fookatchu/pyphotonfile/issues/11?email_source=notifications&email_token=ACUR56VB4TYIFG3W3AU6OMDRA4S45A5CNFSM4KFZWRE2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEKR74AQ#issuecomment-581172738, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACUR56VRH4CBPKTA36GL3PDRA4S45ANCNFSM4KFZWREQ .
-- Com os melhores cumprimentos, Vinicius Silva
Hi, is there any progress regarding this issue?
Not yet, I have been busy with other projects. If anyone else wants to give it a shot, I would be grateful. I currently don't use the Photon anymore, so any help is appreciated!
I use the library version from the master branch. I have a following snippet to create a CBDDLP file from a list of images:
I supplied a single layer with a gradient black/white and used level 8 of anti-aliasing I was expecting to see 8 images - with more a more exposed area of the display. However, that was not the case, neither saw I a gradient. Does the AA feature of this library works?
The file I generated: http://files.honzamrazek.cz/grad2.cbddlp
Could you try the file on your printer? How is the AA feature supposed to work?