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;








1















My goal is to be able to analyze and transform graphic files focusing on the color matrix.



  1. Is it better to operate a Word8 or Integer matrix?

  2. How else can we switch from ByteString to a two-dimensional matrix?

  3. 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









share|improve this question



















  • 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 expect Matrix Integer instead of Matrix [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 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

















1















My goal is to be able to analyze and transform graphic files focusing on the color matrix.



  1. Is it better to operate a Word8 or Integer matrix?

  2. How else can we switch from ByteString to a two-dimensional matrix?

  3. 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









share|improve this question



















  • 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 expect Matrix Integer instead of Matrix [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 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













1












1








1








My goal is to be able to analyze and transform graphic files focusing on the color matrix.



  1. Is it better to operate a Word8 or Integer matrix?

  2. How else can we switch from ByteString to a two-dimensional matrix?

  3. 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









share|improve this question
















My goal is to be able to analyze and transform graphic files focusing on the color matrix.



  1. Is it better to operate a Word8 or Integer matrix?

  2. How else can we switch from ByteString to a two-dimensional matrix?

  3. 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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 is Matrix? I would expect Matrix Integer instead of Matrix [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 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












  • 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 expect Matrix Integer instead of Matrix [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 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







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












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
);



);













draft saved

draft discarded


















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















draft saved

draft discarded
















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현