Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
ciao a tutti,
sono nuovo del forum, quindi se sbaglio qualcosa cercate di capire ...
ho un problemone con elaborazioni di immagini, in pratica vi spiego il mio problema:
ho un array formato da interi, ogni intero è un valore (non segnato!) che puo' andare da 0-65536, ad ogni valore corrisponderà un valore in scala di grigio, cioè fatto 0=nero e 65536=bianco, qualsiesi valore dell'array compreso tra questo range è un valore di grigio piu' o meno intenso...
come faccio a visualizzare l'immagine che si dovrebbe formare?
come faccio poi a definire il range a 16 bit colori di grigio?
in realtà nel mio caso i valori sono a 12 bit, con un range da 0(nero)-4096(bianco) valori possibili di grigio...come faccio a visualizzarli?
ho provato con le JAI ma senza successo, anche perchè non riesco a capire come fare passare l'array nel metodo create di JAI.
Ma ecco la parte più interessante... come operare con Java per applicare questi effetti. Allora, nn è subito immediato, perciò scusa se sn poco chiaro.L'immagine, per essere "lavorata", deve essere inserita in un "contenitore" chiamato BufferedImage. Da li puoi operare per il trattamento del singolo pixel con getRGB e l'immissione del nuovo valore con setRGB.
Ecco la parte più interessante... per lavorare così bisogna andare ad operare a basso livello.
Per adesso so solo questo metodo perciò mi scuso per la mia ignoranza, cmq il valore RGB che il metodo getRGB() ti restituisce è un numero a 32 bit, cioè, mi spiego meglio, in realtà restituisce il valore ARGB (8bit x Alfa,8bit x Red,8bit x Green,8bit x Blue). Quello che devi fare te nn è altro che prendere il singolo canare togliendo gli altri, modificarlo e riinserirlo nella variabile int e "ricolorare" il pixel con setRGB(int rbg).
Nn ci avrai capito niente scommetto , beh, dicono che un'immagine valga + di 1000 parole... spero sia lo stesso anche per gli script .
Questo è parte del codice chè compone il mio programma. Ti ho postato proprio l'algoritmo per la scala dei grigi:
Link:BufferedImage= http://java.sun.com/j2se/1.4.2/docs/api/java/awt/image/Buf ... ColorModel= http://java.sun.com/j2se/1.4.2/docs/api/java/awt/image/Dir ...
ciao Macrosoft, intanto ti saluto e ti ringrazio, sei stato gentilissimo e chiarissimo.
..il problema però rimane, quello che fai tu resta sempre all'interno degli 8bit e cioè 255 tonalità diverse di grigio...a me serve poter visualizzare l'immagine a 12 (o anche a 16) bit di tonalità di grigio...sai come fare?
allora... per il tuo problema in teoria devi usare variabili a 64 bit come gli int 16+16+16+16...
parlavo con un mio amico tempo fa riguardo al problema delle dimensioni e mi ha detto che è un casino la conversione perchè probabilmente java nn gestisce questo tipo di grafica.
Ho provato a vedere sulla guda ufficiale di Java all'indirizzo del BufferedImage e ho trovato questi tipi di file che ti puoi far ritornare con i metodo getRGB
[URL]http://java.sun.com/j2se/1.4.2/docs/api/java/awt/image/Buf ...]
Codice sorgente - presumibilmente Java
TYPE_CUSTOM
publicstaticfinalint TYPE_CUSTOM
Image type is not recognized so it must be a customized image. This type is only used as a return value for the getType() method.
Represents an image with 8-bit RGBA color components packed into integer pixels. The image has a DirectColorModel with alpha. The color data in this image is considered not to be premultiplied with alpha. Whenthis type is used as the imageType argument to a BufferedImage constructor, the created image is consistent with images created in the JDK1.1 and earlier releases.
Represents an image with 8-bit RGBA color components packed into integer pixels. The image has a DirectColorModel with alpha. The color data in this image is considered to be premultiplied with alpha.
Represents an image with 8-bit RGB color components, corresponding to a Windows- or Solaris- style BGR color model, with the colors Blue, Green, and Red packed into integer pixels. There is no alpha. The image has a DirectColorModel.
Represents an image with 8-bit RGB color components, corresponding to a Windows-style BGR color model) with the colors Blue, Green, and Red stored in 3 bytes. There is no alpha. The image has a ComponentColorModel.
Represents an image with 8-bit RGBA color components with the colors Blue, Green, and Red stored in 3 bytes and 1 byte of alpha. The image has a ComponentColorModel with alpha. The color data in this image is considered not to be premultiplied with alpha. Thebyte data is interleaved in a single byte array in the order A, B, G, R from lower to higher byte addresses within each pixel.
Represents an image with 8-bit RGBA color components with the colors Blue, Green, and Red stored in 3 bytes and 1 byte of alpha. The image has a ComponentColorModel with alpha. The color data in this image is considered to be premultiplied with alpha. Thebyte data is interleaved in a single byte array in the order A, B, G, R from lower to higher byte addresses within each pixel.
Represents an opaque byte-packed 1, 2, or 4 bit image. The image has an IndexColorModel without alpha. Whenthis type is used as the imageType argument to the BufferedImage constructor that takes an imageType argument but no ColorModel argument, a 1-bit image is created with an IndexColorModel with two colors in the default sRGB ColorSpace:{0, 0, 0} and {255, 255, 255}.
Images with 2 or 4 bits per pixel may be constructed via the BufferedImage constructor that takes a ColorModel argument by supplying a ColorModel with an appropriate map size.
Images with 8 bits per pixel should use the image types TYPE_BYTE_INDEXED or TYPE_BYTE_GRAY depending on their ColorModel.
Represents an indexed byte image. Whenthis type is used as the imageType argument to the BufferedImage constructor that takes an imageType argument but no ColorModel argument, an IndexColorModel is created with a 256-color 6/6/6 color cube palette with the rest of the colors from 216-255 populated by grayscale values in the default sRGB ColorSpace.
See Also:
Ci ho dato un'occhiata ma nn ho trovato valori di colore superiore agli 8bit perciò la strada del BufferedImage nn è quella giusta....
Nn ho proprio idee al riguardo. magari se scopro qualcosa in più chiedendo ai miei amici ti mado un messaggio. ciao
Ultima modifica effettuata da Macrosoft il 15/05/2007 alle 17:47
si la bufferedImage mette a disposizione quello che cerco: TYPE_USHORT_GRAY, ciè 16bit di toni per il grigio, ma quando provo ad usarla non mi stampa l'immagine ma tutto nero...questo è il problema..
Constructs a ColorModel that translates pixels of the specified number of bits to color/alpha components.The color space is the default RGB ColorSpace, which is sRGB.Pixel values are assumed toinclude alpha information.If color and alpha information are represented in the pixel value as separate spatial bands, the color bands are assumed notto be premultiplied with the alpha value.The transparency typeis java.awt.Transparency.TRANSLUCENT.The transfer type will be the smallest of DataBuffer.TYPE_BYTE, DataBuffer.TYPE_USHORT,or DataBuffer.TYPE_INT that can hold a single pixel (or DataBuffer.TYPE_UNDEFINEDif bits is greater than 32).Since this constructor has no information about the number of bits per color and alpha component, any subclass calling this constructor should override any method that requires this information.
Parameters:
bits - the number of bits of a pixel
Throws:
IllegalArgumentException -if the number of bits in bits is less than 1
.
Adesso... in teoria bisogna settare la lettura del colore dal modo di default a quello che interessa a te...
si, quello lo setto a TYPE_USHORT_GRAY...mannaggia...non so proprio come fare, vorrei postarti un pezzo di codice per fartivedere, ma ho cambiato cosi' tante volte la struttura che non mi ci raccapezzo neanch'io, per questo volevo un aiuto per buttare via tutto e rifare tutto nuovo...