2014-09-08 14 views
5

I recently asked how to convert Float32 or Uint8 arrays into images w pakiecie Images. Dostałem odpowiedź na przypadek Float32, ale nadal mam problem z ustaleniem, jak zapisać tablicę Uint8.Wyeksportuj tablicę Uint8 jako obraz przy użyciu obrazów w Julia

Jako przykład stwórzmy losową Uint8 tablicę używając tradycyjnego systemu Matlab, gdzie wymiary są (m,n,3):

array = rand(Uint8, 50, 50, 3); 
img = convert(Image, array); 

Stosując takie samo podejście jak prac na razie Float32,

imwrite(img, "out.png") 

kończy się niepowodzeniem z komunikatem

ERROR: method 'mapinfo' has no method matching mapinfo(::Type{ImageMagick}, ::Image{Uint8, 3, Image{Uint8, 3, Array{Uint8, 3}}}).

sprawdziłem dokumentację, and it says

If data encodes color information along one of the dimensions of the array (as opposed to using a ColorValue array, from the Color.jl package), be sure to specify the "colordim" and "colorspace" in properties.

Jednak inspekcji img obiektu utworzonego wcześniej pokazuje, że ma colordim = 3 i colorspace = RGB już skonfigurowane, więc nie może to być problem.

Następnie przeszukałem dokumentację dla wszystkich wystąpień MapInfo. W core.md jest jedno zdarzenie:

scalei: a property that controls default contrast scaling upon display. This should be a MapInfo value, to be used for setting the contrast upon display. In the absence of this property, the range 0 to 1 will be used.

Ale nie było informacji o tym, co dokładnie MapInfo celem jest, więc patrzyłem dalej, aw function_reference.md mówi:

Here is how to directly construct the major concrete MapInfo types:

MapNone(T), indicating that the only form of scaling is conversion to type T. This is not very safe, as values "wrap around": for example, converting 258 to a Uint8 results in 0x02, which would look dimmer than 255 = 0xff.

...

i kilka innych przykładów. Więc starałem się określić scalei = MapNone(Uint8) następująco:

img2 = Image(img, colordim = 3, colorspace = "RGB", scalei = MapNone(Uint8)); 
imwrite(img, "out.png") 

ale mam ten sam błąd ponownie.

Jak kodować dane obrazu Uint8 przy użyciu Images w Julia?

+0

Zrobiłem komentarz faktycznie zostawić w starym numerze jesteś powiązany. Ale odpowiedź od juliohm jest poprawna. – tholy

Odpowiedz

6

Pakiet Images.jl zaktualizowany niedawno, upewnij się, że masz najnowszą wersję.

Odpowiedź na to pytanie brzmi:

array = rand(Uint8, 50, 50, 3) 
img = colorim(array) 
Powiązane problemy