File .BMP: analysis and transformationWriting BMP files (Platform Independent)reading a .bmp file in c++PNG to BMP in Haskell (for Gloss)C or Haskell library to find a form in a bmp fileC reading bmp filesFinding a small bmp file in a bigger bmp fileMany bmp files to one file.BMP file cannot be openedreading BMP file with tensorflowBMP File C implementation
Why do all the teams that I have worked with always finish a sprint without completion of all the stories?
Can White Castle?
What can I do with a research project that is my university’s intellectual property?
How does DC work with natural 20?
How would modern naval warfare have to have developed differently for battleships to still be relevant in the 21st century?
What was the Shuttle Carrier Aircraft escape tunnel?
Can there be an UN resolution to remove a country from the UNSC?
How do I handle a table mixing up the DM and the players' roles too often?
Do I need a shock-proof watch for cycling?
Why does the Saturn V have standalone inter-stage rings?
Employer wants to use my work email account after I quit
Is this proposal by U.S. presidential candidate Pete Buttigieg to change the composition of the Supreme Court constitutional?
Do I have to explain the mechanical superiority of the player-character within the fiction of the game?
Array initialization optimization
How many people are necessary to maintain modern civilisation?
Does having had a visa for a country mean I used to be a citizen/national of that country?
If plants "alternate generations" between sporophytes and gametophytes, why don't we say the same of humans?
Dates on degrees don’t make sense – will people care?
Hot coffee brewing solutions for deep woods camping
Why do textbooks often include the solutions to odd or even numbered problems but not both?
How does the spell Remove Curse interact with a Sword of Vengeance?
Silly doubt about tidal effects and Einstein Field Equations
What does the hyphen "-" mean in "tar xzf -"?
Should developer taking test phones home or put in office?
File .BMP: analysis and transformation
Writing BMP files (Platform Independent)reading a .bmp file in c++PNG to BMP in Haskell (for Gloss)C or Haskell library to find a form in a bmp fileC reading bmp filesFinding a small bmp file in a bigger bmp fileMany bmp files to one file.BMP file cannot be openedreading BMP file with tensorflowBMP File C implementation
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
My goal is to be able to analyze and transform graphic files focusing on the color matrix.
- Is it better to operate a Word8 or Integer matrix?
- How else can we switch from ByteString to a two-dimensional matrix?
- Are the procedures used the most efficient?
?
bmpToMatrix :: FilePath -> IO (Matrix [Integer])
bmpToMatrix input = do
Right bmp <- readBMP input
let rgbas = unpackBMPToRGBA32 bmp
(width, height) = bmpDimensions bmp
integers = BS.foldr ((:) . toInteger) [] rgbas
return $ MT.fromList height width $ SP.chunksOf 4 integers
bmpEdit :: (Matrix [Integer] -> Matrix [Integer]) -> FilePath -> FilePath -> IO ()
bmpEdit f input output = do
matrix <- bmpToMatrix input
let matrix' = f matrix
matrixToBMP output matrix'
matrixToByteString :: Matrix [Integer] -> ByteString
matrixToByteString = BS.pack . L.concatMap (L.map fromIntegral) . MT.toList
matrixToBMP :: FilePath -> Matrix [Integer] -> IO ()
matrixToBMP output mt =
writeBMP output $ packRGBA32ToBMP (ncols mt) (nrows mt) $ matrixToByteString mt
haskell bmp bytestring
|
show 3 more comments
My goal is to be able to analyze and transform graphic files focusing on the color matrix.
- Is it better to operate a Word8 or Integer matrix?
- How else can we switch from ByteString to a two-dimensional matrix?
- Are the procedures used the most efficient?
?
bmpToMatrix :: FilePath -> IO (Matrix [Integer])
bmpToMatrix input = do
Right bmp <- readBMP input
let rgbas = unpackBMPToRGBA32 bmp
(width, height) = bmpDimensions bmp
integers = BS.foldr ((:) . toInteger) [] rgbas
return $ MT.fromList height width $ SP.chunksOf 4 integers
bmpEdit :: (Matrix [Integer] -> Matrix [Integer]) -> FilePath -> FilePath -> IO ()
bmpEdit f input output = do
matrix <- bmpToMatrix input
let matrix' = f matrix
matrixToBMP output matrix'
matrixToByteString :: Matrix [Integer] -> ByteString
matrixToByteString = BS.pack . L.concatMap (L.map fromIntegral) . MT.toList
matrixToBMP :: FilePath -> Matrix [Integer] -> IO ()
matrixToBMP output mt =
writeBMP output $ packRGBA32ToBMP (ncols mt) (nrows mt) $ matrixToByteString mt
haskell bmp bytestring
1
I do not see any pure function. Do you have any reason for that?
– Elmex80s
Mar 25 at 16:02
I think I don't understand your observation well. However, if you meant to say that there are no functions for manipulating an rgba matrix, this is due to the fact that for me the functions I published serve as a working "environment". If instead you mean that Matrix is bound to the Integer type (and not for example to the Int type) this is because the Matrix conversion function (matrix library) requires the Integer type. I think that working with Array I wouldn't have this constraint.
– Alberto Capitani
Mar 25 at 19:48
Do you have any real problem?
– Elmex80s
Mar 25 at 22:18
What isMatrix
? I would expectMatrix Integer
instead ofMatrix [Integer]
.
– Elmex80s
Mar 25 at 22:20
1
I voted to close as too broad, because it is. But briefly:Is it better to operate a Word8 or Integer matrix?
Word8
can unbox whileInteger
won't.How else can we switch from ByteString to a two-dimensional matrix?
There are infinite ways, why do you ask?Are the procedures used the most efficient?
No. Lists are obviously not going to be "most efficient" - consider packed structures of word8 values. Consider smaller, notably self contained, examples.
– Thomas M. DuBuisson
Mar 26 at 1:22
|
show 3 more comments
My goal is to be able to analyze and transform graphic files focusing on the color matrix.
- Is it better to operate a Word8 or Integer matrix?
- How else can we switch from ByteString to a two-dimensional matrix?
- Are the procedures used the most efficient?
?
bmpToMatrix :: FilePath -> IO (Matrix [Integer])
bmpToMatrix input = do
Right bmp <- readBMP input
let rgbas = unpackBMPToRGBA32 bmp
(width, height) = bmpDimensions bmp
integers = BS.foldr ((:) . toInteger) [] rgbas
return $ MT.fromList height width $ SP.chunksOf 4 integers
bmpEdit :: (Matrix [Integer] -> Matrix [Integer]) -> FilePath -> FilePath -> IO ()
bmpEdit f input output = do
matrix <- bmpToMatrix input
let matrix' = f matrix
matrixToBMP output matrix'
matrixToByteString :: Matrix [Integer] -> ByteString
matrixToByteString = BS.pack . L.concatMap (L.map fromIntegral) . MT.toList
matrixToBMP :: FilePath -> Matrix [Integer] -> IO ()
matrixToBMP output mt =
writeBMP output $ packRGBA32ToBMP (ncols mt) (nrows mt) $ matrixToByteString mt
haskell bmp bytestring
My goal is to be able to analyze and transform graphic files focusing on the color matrix.
- Is it better to operate a Word8 or Integer matrix?
- How else can we switch from ByteString to a two-dimensional matrix?
- Are the procedures used the most efficient?
?
bmpToMatrix :: FilePath -> IO (Matrix [Integer])
bmpToMatrix input = do
Right bmp <- readBMP input
let rgbas = unpackBMPToRGBA32 bmp
(width, height) = bmpDimensions bmp
integers = BS.foldr ((:) . toInteger) [] rgbas
return $ MT.fromList height width $ SP.chunksOf 4 integers
bmpEdit :: (Matrix [Integer] -> Matrix [Integer]) -> FilePath -> FilePath -> IO ()
bmpEdit f input output = do
matrix <- bmpToMatrix input
let matrix' = f matrix
matrixToBMP output matrix'
matrixToByteString :: Matrix [Integer] -> ByteString
matrixToByteString = BS.pack . L.concatMap (L.map fromIntegral) . MT.toList
matrixToBMP :: FilePath -> Matrix [Integer] -> IO ()
matrixToBMP output mt =
writeBMP output $ packRGBA32ToBMP (ncols mt) (nrows mt) $ matrixToByteString mt
haskell bmp bytestring
haskell bmp bytestring
edited Mar 26 at 6:28
Alberto Capitani
asked Mar 25 at 8:19
Alberto CapitaniAlberto Capitani
665924
665924
1
I do not see any pure function. Do you have any reason for that?
– Elmex80s
Mar 25 at 16:02
I think I don't understand your observation well. However, if you meant to say that there are no functions for manipulating an rgba matrix, this is due to the fact that for me the functions I published serve as a working "environment". If instead you mean that Matrix is bound to the Integer type (and not for example to the Int type) this is because the Matrix conversion function (matrix library) requires the Integer type. I think that working with Array I wouldn't have this constraint.
– Alberto Capitani
Mar 25 at 19:48
Do you have any real problem?
– Elmex80s
Mar 25 at 22:18
What isMatrix
? I would expectMatrix Integer
instead ofMatrix [Integer]
.
– Elmex80s
Mar 25 at 22:20
1
I voted to close as too broad, because it is. But briefly:Is it better to operate a Word8 or Integer matrix?
Word8
can unbox whileInteger
won't.How else can we switch from ByteString to a two-dimensional matrix?
There are infinite ways, why do you ask?Are the procedures used the most efficient?
No. Lists are obviously not going to be "most efficient" - consider packed structures of word8 values. Consider smaller, notably self contained, examples.
– Thomas M. DuBuisson
Mar 26 at 1:22
|
show 3 more comments
1
I do not see any pure function. Do you have any reason for that?
– Elmex80s
Mar 25 at 16:02
I think I don't understand your observation well. However, if you meant to say that there are no functions for manipulating an rgba matrix, this is due to the fact that for me the functions I published serve as a working "environment". If instead you mean that Matrix is bound to the Integer type (and not for example to the Int type) this is because the Matrix conversion function (matrix library) requires the Integer type. I think that working with Array I wouldn't have this constraint.
– Alberto Capitani
Mar 25 at 19:48
Do you have any real problem?
– Elmex80s
Mar 25 at 22:18
What isMatrix
? I would expectMatrix Integer
instead ofMatrix [Integer]
.
– Elmex80s
Mar 25 at 22:20
1
I voted to close as too broad, because it is. But briefly:Is it better to operate a Word8 or Integer matrix?
Word8
can unbox whileInteger
won't.How else can we switch from ByteString to a two-dimensional matrix?
There are infinite ways, why do you ask?Are the procedures used the most efficient?
No. Lists are obviously not going to be "most efficient" - consider packed structures of word8 values. Consider smaller, notably self contained, examples.
– Thomas M. DuBuisson
Mar 26 at 1:22
1
1
I do not see any pure function. Do you have any reason for that?
– Elmex80s
Mar 25 at 16:02
I do not see any pure function. Do you have any reason for that?
– Elmex80s
Mar 25 at 16:02
I think I don't understand your observation well. However, if you meant to say that there are no functions for manipulating an rgba matrix, this is due to the fact that for me the functions I published serve as a working "environment". If instead you mean that Matrix is bound to the Integer type (and not for example to the Int type) this is because the Matrix conversion function (matrix library) requires the Integer type. I think that working with Array I wouldn't have this constraint.
– Alberto Capitani
Mar 25 at 19:48
I think I don't understand your observation well. However, if you meant to say that there are no functions for manipulating an rgba matrix, this is due to the fact that for me the functions I published serve as a working "environment". If instead you mean that Matrix is bound to the Integer type (and not for example to the Int type) this is because the Matrix conversion function (matrix library) requires the Integer type. I think that working with Array I wouldn't have this constraint.
– Alberto Capitani
Mar 25 at 19:48
Do you have any real problem?
– Elmex80s
Mar 25 at 22:18
Do you have any real problem?
– Elmex80s
Mar 25 at 22:18
What is
Matrix
? I would expect Matrix Integer
instead of Matrix [Integer]
.– Elmex80s
Mar 25 at 22:20
What is
Matrix
? I would expect Matrix Integer
instead of Matrix [Integer]
.– Elmex80s
Mar 25 at 22:20
1
1
I voted to close as too broad, because it is. But briefly:
Is it better to operate a Word8 or Integer matrix?
Word8
can unbox while Integer
won't. How else can we switch from ByteString to a two-dimensional matrix?
There are infinite ways, why do you ask? Are the procedures used the most efficient?
No. Lists are obviously not going to be "most efficient" - consider packed structures of word8 values. Consider smaller, notably self contained, examples.– Thomas M. DuBuisson
Mar 26 at 1:22
I voted to close as too broad, because it is. But briefly:
Is it better to operate a Word8 or Integer matrix?
Word8
can unbox while Integer
won't. How else can we switch from ByteString to a two-dimensional matrix?
There are infinite ways, why do you ask? Are the procedures used the most efficient?
No. Lists are obviously not going to be "most efficient" - consider packed structures of word8 values. Consider smaller, notably self contained, examples.– Thomas M. DuBuisson
Mar 26 at 1:22
|
show 3 more comments
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55333669%2ffile-bmp-analysis-and-transformation%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55333669%2ffile-bmp-analysis-and-transformation%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
I do not see any pure function. Do you have any reason for that?
– Elmex80s
Mar 25 at 16:02
I think I don't understand your observation well. However, if you meant to say that there are no functions for manipulating an rgba matrix, this is due to the fact that for me the functions I published serve as a working "environment". If instead you mean that Matrix is bound to the Integer type (and not for example to the Int type) this is because the Matrix conversion function (matrix library) requires the Integer type. I think that working with Array I wouldn't have this constraint.
– Alberto Capitani
Mar 25 at 19:48
Do you have any real problem?
– Elmex80s
Mar 25 at 22:18
What is
Matrix
? I would expectMatrix Integer
instead ofMatrix [Integer]
.– Elmex80s
Mar 25 at 22:20
1
I voted to close as too broad, because it is. But briefly:
Is it better to operate a Word8 or Integer matrix?
Word8
can unbox whileInteger
won't.How else can we switch from ByteString to a two-dimensional matrix?
There are infinite ways, why do you ask?Are the procedures used the most efficient?
No. Lists are obviously not going to be "most efficient" - consider packed structures of word8 values. Consider smaller, notably self contained, examples.– Thomas M. DuBuisson
Mar 26 at 1:22